今天不知何故,当我像往常一样尝试使用
npx nuxi init <project name>
创建一个新的 Nuxt 3 项目时。当我尝试使用 npm install
安装依赖项时,终端给了我一个很长的错误。我也尝试删除lock
文件并使用yarn
&pnpm
代替,但是,结果仍然相同。
版本:
错误信息:
× Client
Compiled with some errors in 9.90s
( ) Server
Hash: 2c24c5888bf3b1c1c416 13:31:53
Version: webpack 4.46.0
Time: 9899ms
Built at: 15/03/2023 1:31:53 pm
Asset Size Chunks Chunk Names
0f675ac.js 2.29 KiB 2 [immutable] runtime
12a4221.js 4.75 KiB 4 [immutable]
1ab12b9.js 44.4 KiB 0 [immutable] app
393869b.js 184 KiB 3 [immutable] vendors/app
LICENSES 336 bytes
ec6d84d.js 72.1 KiB 1 [immutable] commons/app
Entrypoint app = 0f675ac.js ec6d84d.js 393869b.js 1ab12b9.js
WARNING in ./.nuxt/router.js 19:8-14
"export 'default' (imported as 'Router') was not found in 'vue-router'
@ ./.nuxt/index.js
@ ./.nuxt/client.js
@ multi ./.nuxt/client.js
WARNING in ./.nuxt/router.js 34:19-25
"export 'default' (imported as 'Router') was not found in 'vue-router'
@ ./.nuxt/index.js
@ ./.nuxt/client.js
@ multi ./.nuxt/client.js
// The WARNING continues for about 20 more items
//...
//...
ERROR in ./node_modules/vue-router/dist/vue-router.mjs 2157:18-26
Can't import the named export 'computed' from non EcmaScript module (only default export is available)
@ ./.nuxt/router.js
@ ./.nuxt/index.js
@ ./.nuxt/client.js
@ multi ./.nuxt/client.js
ERROR in ./node_modules/vue-router/dist/vue-router.mjs 2158:30-38
Can't import the named export 'computed' from non EcmaScript module (only default export is available)
@ ./.nuxt/router.js
@ ./.nuxt/index.js
@ ./.nuxt/client.js
@ multi ./.nuxt/client.js
// The ERROR continues for about 20 more items.
//...
//...
ERROR Nuxt build error 13:31:53
at WebpackBundler.webpackCompile (C:\Users\user\node_modules\@nuxt\webpack\dist\webpack.js:2127:21)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async WebpackBundler.build (C:\Users\user\node_modules\@nuxt\webpack\dist\webpack.js:2076:5)
at async Builder.build (C:\Users\user\node_modules\@nuxt\builder\dist\builder.js:327:5)
at async Object.invoke (/C:/Users/user/projects/noah2/node_modules/nuxi/dist/chunks/prepare.mjs:45:5)
at async _main (/C:/Users/user/projects/noah2/node_modules/nuxi/dist/cli.mjs:49:20)
npm ERR! code 1
npm ERR! path C:\Users\user\projects\noah2
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c nuxt prepare
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\user\AppData\Local\npm-cache\_logs\2023-03-15T05_31_37_102Z-debug-0.log
我的问题就这些了。提前超级感谢!
将
nuxt
降级为3.2.0
并使用pnpm
对我有用。
这是我的
package.json
{
"private": true,
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview",
"postinstall": "nuxt prepare"
},
"devDependencies": {
"nuxt": "3.2.0"
}
}