nuxt:nodejs编译上的错误

编译过程中报错:
internal/modules/cjs/loader.js:883
throw err;
^

Error: Cannot find module ‘node:util’
Require stack:

  • D:\code\hello\node_modules@nuxt\utils\node_modules\consola\dist\shared\consola.deac7d5a.cjs
  • D:\code\hello\node_modules@nuxt\utils\node_modules\consola\dist\shared\consola.4bbae468.cjs
  • D:\code\hello\node_modules@nuxt\utils\node_modules\consola\dist\index.cjs
  • D:\code\hello\node_modules@nuxt\utils\node_modules\consola\lib\index.cjs
  • D:\code\hello\node_modules@nuxt\utils\dist\utils.js
  • D:\code\hello\node_modules@nuxt\cli\dist\cli-index.js
  • D:\code\hello\node_modules@nuxt\cli\dist\cli.js
  • D:\code\hello\node_modules\nuxt\bin\nuxt.js
    ?[90m at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)?[39m
    ?[90m at Function.Module._load (internal/modules/cjs/loader.js:725:27)?[39m
    ?[90m at Module.require (internal/modules/cjs/loader.js:952:19)?[39m
    ?[90m at require (internal/modules/cjs/helpers.js:88:18)?[39m
    at Object. (D:\code\hello\node_modules?[4m@nuxt?[24m\utils\node_modules?[4mconsola?[24m\dist\shared\consola.deac7d5a.cjs:3:19)
    ?[90m at Module._compile (internal/modules/cjs/loader.js:1063:30)?[39m
    ?[90m at Object.Module._extensions…js (internal/modules/cjs/loader.js:1092:10)?[39m
    ?[90m at Module.load (internal/modules/cjs/loader.js:928:32)?[39m
    ?[90m at Function.Module._load (internal/modules/cjs/loader.js:769:14)?[39m
    ?[90m at Module.require (internal/modules/cjs/loader.js:952:19)?[39m {
    code: ?[32m’MODULE_NOT_FOUND’?[39m,
    requireStack: [
    ?[32m’D:\code\hello\node_modules\@nuxt\utils\node_modules\consola\dist\shared\consola.deac7d5a.cjs’?[39m,
    ?[32m’D:\code\hello\node_modules\@nuxt\utils\node_modules\consola\dist\shared\consola.4bbae468.cjs’?[39m,
    ?[32m’D:\code\hello\node_modules\@nuxt\utils\node_modules\consola\dist\index.cjs’?[39m,
    ?[32m’D:\code\hello\node_modules\@nuxt\utils\node_modules\consola\lib\index.cjs’?[39m,
    ?[32m’D:\code\hello\node_modules\@nuxt\utils\dist\utils.js’?[39m,
    ?[32m’D:\code\hello\node_modules\@nuxt\cli\dist\cli-index.js’?[39m,
    ?[32m’D:\code\hello\node_modules\@nuxt\cli\dist\cli.js’?[39m,
    ?[32m’D:\code\hello\node_modules\nuxt\bin\nuxt.js’?[39m
    ]
    }

这是什么问题呢?
nodejs版本不对?
可以先升级一下nodejs版本:
#npm install [email protected]
安装缺少的插件:

npm install ufo

#npm install utils

还报错误:
【npm ERR! Unexpected end of JSON input while parsing near ‘…sh_time":144935090300’】
这时可以先执行下面的命令:

npm cache clean --force
然后再执行npm install就可以了!
如果执行失败,请先升级npm,即npm i -g npm, 最后再执行npm cache clean --force, 最后再npm install.(最好是执行指定的npm版本,到时可能会出错)
ERROR: npm v10.2.4 is known not to run on Node.js v13.4.0. This version of npm supports the following node versions: ^18.17.0 || >=20.5.0. You can find the latest version at https://nodejs.org/
执行出错了,还是需要升级!
#npm install -g [email protected]

最终编译成功!
#npm run dev
#npm run build

你可能感兴趣的:(前端,javascript,html,vue.js)