我在npm中遇到了这种问题。顺便说一下,我正在使用VSCode,我的笔记本电脑刚刚格式化,我的操作系统是Ubuntu。当我安装某些东西时,我遇到的错误是:
npm ERR! code MODULE_NOT_FOUND
npm ERR! cannot find module 'encoding'
// Log
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'install', '-g', 'jshint' ]
2 info using npm@5.8.0
3 info using node@v8.11.2
4 verbose npm-session 94ee8611aa9e8514
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 silly fetchPackageMetaData error for jshint@latest Cannot find module 'encoding'
8 verbose stack Error: Cannot find module 'encoding'
8 verbose stack at Function.Module._resolveFilename (module.js:547:15)
8 verbose stack at Function.Module._load (module.js:474:25)
8 verbose stack at Module.require (module.js:596:17)
8 verbose stack at require (internal/module.js:11:18)
8 verbose stack at Object.<anonymous> (/usr/share/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/node-fetch-npm/src/body.js:13:17)
8 verbose stack at Module._compile (module.js:652:30)
8 verbose stack at Object.Module._extensions..js (module.js:663:10)
8 verbose stack at Module.load (module.js:565:32)
8 verbose stack at tryModuleLoad (module.js:505:12)
8 verbose stack at Function.Module._load (module.js:497:3)
8 verbose stack at Module.require (module.js:596:17)
8 verbose stack at require (internal/module.js:11:18)
8 verbose stack at Object.<anonymous> (/usr/share/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/node-fetch-npm/src/index.js:15:14)
8 verbose stack at Module._compile (module.js:652:30)
8 verbose stack at Object.Module._extensions..js (module.js:663:10)
8 verbose stack at Module.load (module.js:565:32)
9 verbose cwd /opt/lampp/htdocs/My Website #1
10 verbose Linux 4.18.0-parrot8-amd64
11 verbose argv "/usr/bin/node" "/usr/bin/npm" "install" "-g" "jshint"
12 verbose node v8.11.2
13 verbose npm v5.8.0
14 error code MODULE_NOT_FOUND
15 error Cannot find module 'encoding'
16 verbose exit [ 1, true ]
我尝试重新安装Node.js/npm,但仍无法正常工作。
encoding
包中还是所有包都一样?正如你所说,你格式化了你的操作系统,我怀疑这是任何一个包的问题。我也想请你检查npmrc
。你能把那些细节也发出来吗? - CRayen