用纱线安装的新鲜Nuxtjs不起作用



我简单地创建了一个新的next应用程序(按照文档):

yarn create nuxt-app appname

然后切换到目录并运行(按照文档):

yarn dev

并得到以下错误:

✖ Nuxt Fatal Error                                                                                                                                                                                                │
│                                                                                                                                                                                                                     │
│   Error: @nuxt/components tried to access consola (a peer dependency) but it isn't provided by its ancestors; this makes the require call ambiguous and unsound.                                                    │
│                                                                                                                                                                                                                     │
│   Required package: consola                                                                                                                                                                                         │
│   Required by: @nuxt/components@virtual:4eff43f3a560be194e6097f872c9d8ed0666b260b73fc7573cd09c38d17c2e2d252932f70636f4f4a6035fee79be6a699b4f9693d4a20ba4eb5c9b359f2413a9#npm:2.1.8 (via                             │
│   /home/ev/Documents/Projects/firebase-test/f-test/.yarn/__virtual__/@nuxt-components-virtual-7192147023/0/cache/@nuxt-components-npm-2.1.8-189d4bc3ff-b2ab70da20.zip/node_modules/@nuxt/components/dist/)          │
│                                                                                                                                                                                                                     │
│   Ancestor breaking the chain: nuxt@npm:2.15.7                                                                                                                                                                      │
│                                                                                                                                                                                                                     │
│                                                                                                                                                                                                                     │
│   Require stack:                                                                                                                                                                                                    │
│   -                                                                                                                                                                                                                 │
│   /home/ev/Documents/Projects/firebase-test/f-test/.yarn/__virtual__/@nuxt-components-virtual-7192147023/0/cache/@nuxt-components-npm-2.1.8-189d4bc3ff-b2ab70da20.zip/node_modules/@nuxt/components/dist/index.js   

为什么会发生这种情况?我正在运行Node v14.16.0和yarn v3.0.0,我在Linux Mint上。

给最初提出问题的人答复可能有点晚,但我想我找到了问题的答案。

下面是我在终端中使用ls -lahA第一次构建失败后看到的结果:

drwxrwxr-x 2 test test 4,0K 2022-06-29 15:50 components
drwxrwxr-x 7 test test 4,0K 2022-06-29 15:50 .git
drwxrwxr-x 2 test test 4,0K 2022-06-29 15:50 pages
drwxrwxr-x 2 test test 4,0K 2022-06-29 15:50 static
drwxrwxr-x 2 test test 4,0K 2022-06-29 15:50 store
drwxrwxr-x 4 test test 4,0K 2022-06-29 15:50 .yarn
-rw-rw-r-- 1 test test  207 2022-06-29 15:50 .editorconfig
-rw-rw-r-- 1 test test 1,3K 2022-06-29 15:50 .gitignore
-rw-rw-r-- 1 test test 1001 2022-06-29 15:50 nuxt.config.js
-rw-rw-r-- 1 test test  394 2022-06-29 15:50 package.json
-rwxr-xr-x 1 test test 1,1M 2022-06-29 15:50 .pnp.cjs <-----
-rw-r--r-- 1 test test 8,5K 2022-06-29 15:50 .pnp.loader.mjs <-----
-rw-rw-r-- 1 test test 2,8K 2022-06-29 15:50 README.md
-rw-rw-r-- 1 test test 375K 2022-06-29 15:50 yarn.lock

为了解决这个问题,我删除了".pnp. cj"one_answers";.pnp.loader.mjs"文件并添加了".yarnrc.yml"来自其他项目的文件。".yarnrc.yml"文件只包含一行:

nodeLinker: node-modules

然后我写yarn在终端中,一切正常,我可以使用yarn dev再一次,一切都好。

我希望它有帮助。对不起,我的英语可能不太好……

对我来说,我只是运行npm install,然后yarn install像魅力一样工作。

最新更新