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

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

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

我尝试了以下操作:

  1. 删除node_modules和package-lock

    npm cache clean --force
    npm i
    npm ci
    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

{
  &quot;name&quot;: &quot;test&quot;,
  &quot;version&quot;: &quot;1.0.0&quot;,
  &quot;private&quot;: true,
  &quot;scripts&quot;: {
    &quot;dev&quot;: &quot;nuxt&quot;,
    &quot;build&quot;: &quot;nuxt build&quot;,
    &quot;start&quot;: &quot;nuxt start&quot;,
    &quot;generate&quot;: &quot;nuxt generate&quot;
  },
  &quot;dependencies&quot;: {
    &quot;bootstrap&quot;: &quot;^4.6.2&quot;,
    &quot;bootstrap-vue&quot;: &quot;^2.22.0&quot;,
    &quot;core-js&quot;: &quot;^3.25.3&quot;,
    &quot;nuxt&quot;: &quot;^2.15.8&quot;,
    &quot;vue&quot;: &quot;^2.7.10&quot;,
    &quot;vue-server-renderer&quot;: &quot;^2.7.10&quot;,
    &quot;vue-template-compiler&quot;: &quot;^2.7.10&quot;
  },
  &quot;devDependencies&quot;: {}
}

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:

确定