我使用以下命令创建了一个新的 nuxt 2 项目
npm init nuxt-app <project-name>
在
npm install
命令之后,当我尝试使用 npm run dev
运行它时,它会抛出以下错误(附图)
内部/模块/cjs/loader.js:883 抛出错误;
^
错误:找不到模块“node:util” 需要堆栈:
包.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": {}
}
节点版本:v14.16.1 npm 版本:6.14.12 nuxt版本:2.15.8
我尝试过以下方法:
删除node_modules和package-lock npm 缓存清理 --force 尼普我 国家管理委员会 npm 运行开发
安装 nuxt utils
这些都不起作用
问题已通过@r-rodrigues 更改解决了
the nuxt version in package.json to "2.15.8" and removed the ^ (caret symbol) , which was upgrading the dependencies