Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Nuxt Generator fails with npm; pinia requires extra config

未关闭
#367 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
45/100
Issue 类型
文档
描述清晰度
基本清楚
活跃度
停滞
技术栈
nuxt
领域
documentation

调研方向

先查看 Nuxt 生成器文档和 issue 中链接的 README 部分,然后重新执行 npm 命令以确认该限制。检查 Nuxt 安装指南、package.json 说明和 nuxt.config.ts 示例;当文档说明 yarn 的使用方式,并包含所需的 npm 和 Pinia 配置步骤时,即表示完成。

由索引模型根据 Issue 内容生成。

描述

API Platform version(s) affected: 3.0.9

Description

Following the steps for the Nuxt generator at https://api-platform.com/docs/create-client/nuxt/ failed. Specifically:

  • I was unable to use npm to create the nuxt client - I had to use yarn (which worked). I assumed that based on the README I should be able to use npm.
  • Installing pinia requires additional steps. Opening the Nuxt site and navigating to my resource showed this error in browser: getActivePinia was called with no active Pinia. Did you forget to install pinia? const pinia = createPinia() app.use(pinia) This will fail in production.

How to reproduce: npm failure

When attempting to use the Nuxt generator with npm:

npm create @api-platform/client https://demo.api-platform.com . --generator nuxt --resource foo

it failed with the following output:

Usage: create-client entrypoint outputDirectory

Generate apps built with Next, Nuxt, Quasar, React, React Native, Vue or Vuetify for any API documented using Hydra or OpenAPI

Options:
  -V, --version                                 output the version number
  -r, --resource [resourceName]                 Generate CRUD for the given resource
  -p, --hydra-prefix [hydraPrefix]              The hydra prefix used by the API (default: "hydra:")
  --username [username]                         Username for basic auth (Hydra only)
  --password [password]                         Password for basic auth (Hydra only)
  --bearer [bearer]                             Token for bearer auth (Hydra only)
  -g, --generator [generator]                   The generator to use, one of "next", "nuxt", "quasar", "react", "react-native", "typescript", "vue", "vuetify" or a path to a
                                                custom generator of your choice (default: "next")
  -t, --template-directory [templateDirectory]  The templates directory base to use. Final directory will be ${templateDirectory}/${generator} (default:
                                                "/Users/rs/.npm/_npx/eeb701ba6cc95913/node_modules/@api-platform/create-client/lib/../templates/")
  -f, --format [hydra|openapi3|openapi2]        "hydra", "openapi3" or "openapi2" (default: "hydra")
  -s, --server-path [serverPath]                Path to express server file to allow route dynamic addition (Next.js generator only)
  -h, --help                                    display help for command

Documentation should be added to say that the Nuxt generator can only be used with yarn.

How to reproduce: pinia installation failure

Installation instructions are only given using yarn. I assumed they would also work with npm but that's not the case. The steps at https://pinia.vuejs.org/ssr/nuxt.html should be followed for npm, which requires adding an overrides to package.json as well as explicitly installing the pinia module.

How to reproduce: pinia failure when opening the Nuxt site in a browser

As per https://pinia.vuejs.org/ssr/nuxt.html

    modules: [
        '@pinia/nuxt',
    ],

should be added to nuxt.config.ts

主要语言
TypeScript
星标
376
派生
132
PR 合并指标
30 天内没有已合并 PR

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

api-platform/create-client 的其他 Issue

查看 api-platform/create-client 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。