更新npm:找不到模块'y18n'npm ERR?

时间:2018-09-16 15:35:57

标签: node.js npm

我有一段时间没有更新npm了。我的版本是5.8.0 当前是6.4.1

我尝试了此命令,但是没有用:

$ npm install npm@latest -g
npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module 'y18n'

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\erjan222\AppData\Roaming\npm-cache\_logs\2018-09-16T14_16_55_797Z-debug.log

在npm论坛上搜索类似主题没有帮助- y18-n

debug.log文件具有以下内容:

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Users\\erjan222\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'install',
1 verbose cli   'npm@latest',
1 verbose cli   '-g' ]
2 info using npm@5.8.0
3 info using node@v8.10.0
4 verbose stack Error: Cannot find module 'y18n'
4 verbose stack     at Function.Module._resolveFilename (module.js:547:15)
4 verbose stack     at Function.Module._load (module.js:474:25)
4 verbose stack     at Module.require (module.js:596:17)
4 verbose stack     at require (internal/module.js:11:18)
4 verbose stack     at Object.<anonymous> (C:\Users\erjan222\AppData\Roaming\npm\node_modules\npm\node_modules\cacache\lib\util\y.js:4:14)
4 verbose stack     at Module._compile (module.js:652:30)
4 verbose stack     at Object.Module._extensions..js (module.js:663:10)
4 verbose stack     at Module.load (module.js:565:32)
4 verbose stack     at tryModuleLoad (module.js:505:12)
4 verbose stack     at Function.Module._load (module.js:497:3)
4 verbose stack     at Module.require (module.js:596:17)
4 verbose stack     at require (internal/module.js:11:18)
4 verbose stack     at Object.<anonymous> (C:\Users\erjan222\AppData\Roaming\npm\node_modules\npm\node_modules\cacache\lib\entry-index.js:13:11)
4 verbose stack     at Module._compile (module.js:652:30)
4 verbose stack     at Object.Module._extensions..js (module.js:663:10)
4 verbose stack     at Module.load (module.js:565:32)
5 verbose cwd C:\Users\erjan222\Desktop
6 verbose Windows_NT 6.1.7601
7 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\erjan222\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" "npm@latest" "-g"
8 verbose node v8.10.0
9 verbose npm  v5.8.0
10 error code MODULE_NOT_FOUND
11 error Cannot find module 'y18n'
12 verbose exit [ 1, true ]

2 个答案:

答案 0 :(得分:2)

I recommend that you try install y18n first then upgrade npm like this:

npm install y18n@4.0.0 -g
npm install npm@latest -g

Or install 8.12.0 LTS from nodejs

答案 1 :(得分:2)

首先,将您的npm升级到最新版本,然后使用此命令安装y18n模块
npm i -g npm-upgrade
npm i y18n

如果您想忽略 npm更新中的特定模块,请参考此链接答案。
npm install: Is there a way to ignore a particular dependency