npm问题汇总

1、npm.config.loaded ? npm.config.get('_exit') : true

Error: EINVAL: invalid argument, mkdir 'G:\blog_github\“F:\SP\node\node_global”;'
TypeError: Cannot read property 'loaded' of undefined
    at exit (E:\博客\node\node_modules\npm\lib\utils\error-handler.js:97:27)
    at errorHandler (E:\博客\node\node_modules\npm\lib\utils\error-handler.js:216:3)
    at E:\博客\node\node_modules\npm\bin\npm-cli.js:78:20
    at cb (E:\博客\node\node_modules\npm\lib\npm.js:225:22)
    at E:\博客\node\node_modules\npm\lib\npm.js:263:24
    at E:\博客\node\node_modules\npm\lib\config\core.js:81:7
    at Array.forEach (<anonymous>)
    at E:\博客\node\node_modules\npm\lib\config\core.js:80:13
    at f (E:\博客\node\node_modules\npm\node_modules\once\once.js:25:25)
    at afterExtras (E:\博客\node\node_modules\npm\lib\config\core.js:171:20)
E:\博客\node\node_modules\npm\lib\utils\error-handler.js:97
  var doExit = npm.config.loaded ? npm.config.get('_exit') : true
                          ^

TypeError: Cannot read property 'loaded' of undefined
    at exit (E:\博客\node\node_modules\npm\lib\utils\error-handler.js:97:27)
    at process.errorHandler (E:\博客\node\node_modules\npm\lib\utils\error-handler.js:216:3)
    at process.emit (events.js:210:5)
    at process._fatalException (internal/process/execution.js:150:25)

解决

  • 第一种:

在编辑器中打开以下文件:
/usr/local/lib/node_modules/npm/node_modules/uid-number/uid-number.js
到 11 行,将 uidSupport = process.getuid && process.setuid 修改为 uidSupport = false

  • 第二种:

删除 /Users/{user目录}/.npmrc

  • 第三种:

全局安装变量被设置成空文件夹
①检测自己的全局安装位置:npm config get prefix
②找到之前安装node.js的位置,将node.js的原文件夹复制一份,到刚才的根据命令得到的全局安装位置,复制过去!

https://blog.csdn.net/qq_43511842/article/details/103686452

2、npm link

通过 npm link 可以很容易的调试开发库,有几个需要注意的地方:

  • 目录地址,看一下要链接的地址是不是正确
  • Mac 上需要使用 sudo

3、设置代理

$ npm config set proxy=http://127.0.0.1:8087
$ npm config delete proxy
$ npm config set registry=http://registry.npmjs.org

4、奇怪报错

Unexpected end of JSON input while parsing near '...75189a47b39759b783e",'

5、用户名

# 查看
$ git config user.name
$ git config user.email

#  设置
$ git config --global user.name "username"
$ git config --global user.email "email"
posted @ 2020-09-18 21:26  MelodyJerry  阅读(443)  评论(0编辑  收藏  举报
没有伞的孩子必须努力奔跑!|
载入天数...载入时分秒...
(っ•̀ω•́)っ✎⁾⁾ 开心每一天