npm不能安装任何包,报错:npm WARN onload-script failed to require onload script npm-autoinit/autoinit及解决方法

想要利用Hexo搭建一个博客,但是安装时npm一直报错,不仅仅是Hexo包,连别的其他包也不行,会提示下面的一堆错误

npm WARN onload-script failed to require onload script npm-autoinit/autoinit

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
npm WARN onload-script failed to require onload script npm-autoinit/autoinit
npm WARN onload-script Error: Cannot find module 'npm-autoinit/autoinit'
npm WARN onload-script     at Function.Module._resolveFilename (module.js:325:15)
npm WARN onload-script     at Function.Module._load (module.js:276:25)
npm WARN onload-script     at Module.require (module.js:353:17)
npm WARN onload-script     at require (internal/module.js:12:17)
npm WARN onload-script     at cb (D:\javasoft\nodejs\node_modules\npm\lib\npm.js:289:9)
npm WARN onload-script     at D:\javasoft\nodejs\node_modules\npm\lib\npm.js:382:14
npm WARN onload-script     at D:\javasoft\nodejs\node_modules\npm\lib\config\core.js:82:7
npm WARN onload-script     at Array.forEach (native)
npm WARN onload-script     at D:\javasoft\nodejs\node_modules\npm\lib\config\core.js:81:13
npm WARN onload-script     at f (D:\javasoft\nodejs\node_modules\npm\node_modules\once\once.js:17:25)
npm WARN onload-script  { [Error: Cannot find module 'npm-autoinit/autoinit'] code: 'MODULE_NOT_FOUND' }
npm WARN onload-script failed to require onload script npm-autoinit/autoinit
npm WARN onload-script Error: Cannot find module 'npm-autoinit/autoinit'
npm WARN onload-script     at Function.Module._resolveFilename (module.js:325:15)
npm WARN onload-script     at Function.Module._load (module.js:276:25)
npm WARN onload-script     at Module.require (module.js:353:17)
npm WARN onload-script     at require (internal/module.js:12:17)
npm WARN onload-script     at cb (D:\javasoft\nodejs\node_modules\npm\lib\npm.js:289:9)
npm WARN onload-script     at D:\javasoft\nodejs\node_modules\npm\lib\npm.js:382:14
npm WARN onload-script     at D:\javasoft\nodejs\node_modules\npm\lib\config\core.js:82:7
npm WARN onload-script     at Array.forEach (native)
npm WARN onload-script     at D:\javasoft\nodejs\node_modules\npm\lib\config\core.js:81:13
npm WARN onload-script     at f (D:\javasoft\nodejs\node_modules\npm\node_modules\once\once.js:17:25)
npm WARN onload-script  { [Error: Cannot find module 'npm-autoinit/autoinit'] code: 'MODULE_NOT_FOUND' }

 

卸了node重装,没有作用。

内网找,没有找到。外网主要看Stackoverflow,好像也没有非常契合的,并不准确是这个错误

后在Hexo的github上提了一个issue,终于找到方法(而且顺着回答找下去,还是有很多人遇到的,找解决方案还是要去外网啊):

 

解决方法:先输入下面这行命令,再尝试,就可以了

 

$ npm config delete onload-script npm-autoinit/autoinit

 

posted on   Calvino  阅读(933)  评论(0编辑  收藏  举报

导航

< 2025年1月 >
29 30 31 1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31 1
2 3 4 5 6 7 8
点击右上角即可分享
微信分享提示