英文:
Error: Cannot find module 'node:util' while running the nuxt project using npm run command
问题
我使用以下命令创建了一个新的Nuxt 2项目:
npm init nuxt-app <project-name>
在运行npm run dev
命令时,出现了以下错误(附带图像):
internal/modules/cjs/loader.js:883
throw err;
^
Error: Cannot find module 'node:util'
Require stack:
Package.json:
{
"name": "test",
"version": "1.0.0",
"private": true,
"scripts": {
"dev": "nuxt",
"build": "nuxt build",
"start": "nuxt start",
"generate": "nuxt generate"
},
"dependencies": {
"bootstrap": "^4.6.2",
"bootstrap-vue": "^2.22.0",
"core-js": "^3.25.3",
"nuxt": "^2.15.8",
"vue": "^2.7.10",
"vue-server-renderer": "^2.7.10",
"vue-template-compiler": "^2.7.10"
},
"devDependencies": {}
}
Node版本:v14.16.1
npm版本:6.14.12
Nuxt版本:2.15.8
我尝试了以下操作:
-
删除node_modules和package-lock
npm cache clean --force npm i npm ci npm run dev
-
安装nuxt-utils
但都没有起作用。
英文:
I created a new nuxt 2 project using the following commands
npm init nuxt-app <project-name>
after the npm install
command when i try to run it using npm run dev
it throws the follwing error (attached image)
>
> internal/modules/cjs/loader.js:883
> throw err;
> > ^
>
> Error: Cannot find module 'node:util'
> Require stack:
Package.json
{
"name": "test",
"version": "1.0.0",
"private": true,
"scripts": {
"dev": "nuxt",
"build": "nuxt build",
"start": "nuxt start",
"generate": "nuxt generate"
},
"dependencies": {
"bootstrap": "^4.6.2",
"bootstrap-vue": "^2.22.0",
"core-js": "^3.25.3",
"nuxt": "^2.15.8",
"vue": "^2.7.10",
"vue-server-renderer": "^2.7.10",
"vue-template-compiler": "^2.7.10"
},
"devDependencies": {}
}
node version : v14.16.1
npm version : 6.14.12
nuxt version: 2.15.8
i've tried the following:
-
deleting node_modules and package-lock
npm cache clean --force
npm i
npm ci
npm run dev -
installing nuxt utils
none of these work
答案1
得分: 0
这个问题已经被 @r-rodrigues 解决了,他将 package.json
中的 Nuxt 版本更改为 "2.15.8",并删除了升级依赖项的 ^(脱字符号)。
英文:
The problem has been solved by @r-rodrigues changing the nuxt version in package.json to "2.15.8" and removed the ^ (caret symbol) , which was upgrading the dependencies
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论