Error: 在运行 npm run 命令时找不到模块 ‘node:util’ 的情况。

huangapple go评论138阅读模式
英文:

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命令时,出现了以下错误(附带图像):

  1. internal/modules/cjs/loader.js:883
  2. throw err;
  3. ^
  4. Error: Cannot find module 'node:util'
  5. Require stack:

Package.json:

  1. {
  2. "name": "test",
  3. "version": "1.0.0",
  4. "private": true,
  5. "scripts": {
  6. "dev": "nuxt",
  7. "build": "nuxt build",
  8. "start": "nuxt start",
  9. "generate": "nuxt generate"
  10. },
  11. "dependencies": {
  12. "bootstrap": "^4.6.2",
  13. "bootstrap-vue": "^2.22.0",
  14. "core-js": "^3.25.3",
  15. "nuxt": "^2.15.8",
  16. "vue": "^2.7.10",
  17. "vue-server-renderer": "^2.7.10",
  18. "vue-template-compiler": "^2.7.10"
  19. },
  20. "devDependencies": {}
  21. }

Node版本:v14.16.1
npm版本:6.14.12
Nuxt版本:2.15.8

我尝试了以下操作:

  1. 删除node_modules和package-lock

    1. npm cache clean --force
    2. npm i
    3. npm ci
    4. npm run dev
  2. 安装nuxt-utils

但都没有起作用。

英文:

I created a new nuxt 2 project using the following commands

npm init nuxt-app &lt;project-name&gt;

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

  1. {
  2. &quot;name&quot;: &quot;test&quot;,
  3. &quot;version&quot;: &quot;1.0.0&quot;,
  4. &quot;private&quot;: true,
  5. &quot;scripts&quot;: {
  6. &quot;dev&quot;: &quot;nuxt&quot;,
  7. &quot;build&quot;: &quot;nuxt build&quot;,
  8. &quot;start&quot;: &quot;nuxt start&quot;,
  9. &quot;generate&quot;: &quot;nuxt generate&quot;
  10. },
  11. &quot;dependencies&quot;: {
  12. &quot;bootstrap&quot;: &quot;^4.6.2&quot;,
  13. &quot;bootstrap-vue&quot;: &quot;^2.22.0&quot;,
  14. &quot;core-js&quot;: &quot;^3.25.3&quot;,
  15. &quot;nuxt&quot;: &quot;^2.15.8&quot;,
  16. &quot;vue&quot;: &quot;^2.7.10&quot;,
  17. &quot;vue-server-renderer&quot;: &quot;^2.7.10&quot;,
  18. &quot;vue-template-compiler&quot;: &quot;^2.7.10&quot;
  19. },
  20. &quot;devDependencies&quot;: {}
  21. }

node version : v14.16.1
npm version : 6.14.12
nuxt version: 2.15.8

i've tried the following:

  1. deleting node_modules and package-lock
    npm cache clean --force
    npm i
    npm ci
    npm run dev

  2. installing nuxt utils

none of these work

screenshot

答案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 &quot;2.15.8&quot; and removed the ^ (caret symbol) , which was upgrading the dependencies

huangapple
  • 本文由 发表于 2023年8月4日 20:46:58
  • 转载请务必保留本文链接:https://go.coder-hub.com/76836058.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定