想要利用Hexo搭建一个博客,但是安装时npm一直报错,不仅仅是Hexo包,连别的其他包也不行,会提示下面的一堆错误
npm WARN onload-script failed to require onload script npm-autoinit/autoinit
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重装,没有作用。
内网找,没有找到。外网主要看*,好像也没有非常契合的,并不准确是这个错误
后在Hexo的github上提了一个issue,终于找到方法(而且顺着回答找下去,还是有很多人遇到的,找解决方案还是要去外网啊):
解决方法:先输入下面这行命令,再尝试,就可以了
$ npm config delete onload-script npm-autoinit/autoinit