【笔记】Error: Cannot find module ‘node:util‘问题解决

控制台 安装 Vue-Cli 最后一步出现 Error: Cannot find module 'node:util' 问题解决方案

1.问题

C:\Windows\System32>cnpm install -g @vue/cli@4.0.3
internal/modules/cjs/loader.js:638
    throw err;
    ^

Error: Cannot find module 'node:util'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (C:\Users\DELL\AppData\Roaming\npm\node_modules\cnpm\bin\cnpm:3:15)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)

2.解决方案

npm 与 cnpm 版本不匹配,需要匹配新的cnpm(记得先删除之前的)

npm uninstall cnpm

当前npm版本

C:\Windows\System32>npm -v
6.9.0

安装cnpm指定版本:

C:\Windows\System32>npm install -g cnpm@7.1.1 --registry=https://registry.npm.taobao.org

安装成功后显示内容如下:

npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated @npmcli/move-file@1.1.2: This functionality has been moved to @npmcli/fs
C:\Users\DELL\AppData\Roaming\npm\cnpm -> C:\Users\DELL\AppData\Roaming\npm\node_modules\cnpm\bin\cnpm
npm WARN urllib@2.41.0 requires a peer of proxy-agent@^5.0.0 but none is installed. You must install peer dependencies yourself.

+ cnpm@7.1.1
added 418 packages from 137 contributors, removed 278 packages, updated 215 packages and moved 10 packages in 45.271s

当前cnpm版本:cnpm -v

cnpm7.1.1

安装 webpack 和 webpack-cli , 指令: npm install webpack@4.41.2 webpack-cli -D

npm install webpack@4.41.2 webpack-cli -D

安装 vue-cli cnpm install -g @vue/cli@4.0.3

cnpm install -g @vue/cli@4.0.3

 显示以下内容即安装 vue-cli 成功

 版本情况


C:\Windows\System32>cnpm -v
cnpm@7.1.1 (C:\Users\DELL\AppData\Roaming\npm\node_modules\cnpm\lib\parse_argv.js)
npm@6.14.18 (C:\Users\DELL\AppData\Roaming\npm\node_modules\cnpm\node_modules\npm\lib\npm.js)
node@10.16.3 (D:\Program Files (x86)\nodejs10.16\node.exe)
npminstall@5.8.1 (C:\Users\DELL\AppData\Roaming\npm\node_modules\cnpm\node_modules\npminstall\lib\index.js)
prefix=C:\Users\DELL\AppData\Roaming\npm
win32 x64 10.0.22621
registry=https://registry.npmmirror.com

  • 41
    点赞
  • 56
    收藏
    觉得还不错? 一键收藏
  • 8
    评论
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值