参考这个安装node, http://xiaoyaojones.blog.163.com/blog/static/28370125201351501113581/
在这一步
启动cmd,输入
npm config set prefix "C:\Program Files\nodejs\node_global" 以及 npm config set cache “C:\Program Files\nodejs\node_cache”
输入“npm install express -g” 。安装无效。
想恢复原有的设置
执行过这个命令 npm config set prefix null npm config set cache null .接下来。就报了死亡bug
C:\Users\One>npm install express TypeError: Path must be a string. Received null at assertPath (path.js:8:11) at Object.win32.resolve (path.js:130:5) at Conf.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\config\load-prefix.js:26:21) at Conf.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\config\load-prefix.js:16:24) at Conf.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:242:18) at nextTickCallbackWith0Args (node.js:419:9) at process._tickCallback (node.js:348:13)
C:\Program Files\nodejs\node_modules\npm\lib\npm.js:29 throw new Error(‘npm.load() required’) ^
Error: npm.load() required at Object.npm.config.get (C:\Program Files\nodejs\node_modules\npm\lib\npm.js:29:11) at exit (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:58:40) at process.errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:385:3) at emitOne (events.js:77:13) at process.emit (events.js:169:7) at process._fatalException (node.js:223:26) TypeError: Path must be a string. Received null at assertPath (path.js:8:11) at Object.win32.resolve (path.js:130:5) at Conf.setUser (C:\Program Files\nodejs\node_modules\npm\lib\config\set-user.js:21:21) at Conf.loadExtras (C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:235:8) at Conf.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:174:12) at Conf.g (events.js:260:16) at emitOne (events.js:77:13) at Conf.emit (events.js:169:7) at ConfigChain._resolve (C:\Program Files\nodejs\node_modules\npm\node_modules\config-chain\index.js:281:34) at ConfigChain.add (C:\Program Files\nodejs\node_modules\npm\node_modules\config-chain\index.js:259:10)
C:\Program Files\nodejs\node_modules\npm\lib\npm.js:29 throw new Error(‘npm.load() required’) ^
Error: npm.load() required at Object.npm.config.get (C:\Program Files\nodejs\node_modules\npm\lib\npm.js:29:11) at exit (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:58:40) at process.errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:385:3) at emitOne (events.js:77:13) at process.emit (events.js:169:7) at process._fatalException (node.js:223:26)
在c盘下查找npm,发现在用户目录下有个.npmrc文件,删掉保存,npm又可以用了。***