欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

错误解决npm ERR! not a package /usr/local/bin/n

程序员文章站 2022-03-23 18:44:31
...
$ sudo npm install n -g
npm ERR! not a package /usr/local/bin/n
npm ERR! addLocal Could not install /usr/local/bin/n
npm ERR! Darwin 15.4.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "n" "-g"
npm ERR! node v4.4.2
npm ERR! npm  v3.8.6
npm ERR! path /tmp/npm-64647-8937f140/unpack-b3c9aef5/package.json
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall open

npm ERR! enoent ENOENT: no such file or directory, open '/tmp/npm-64647-8937f140/unpack-b3c9aef5/package.json'
npm ERR! enoent ENOENT: no such file or directory, open '/tmp/npm-64647-8937f140/unpack-b3c9aef5/package.json'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! Please include the following file with any support request:
npm ERR!     /usr/local/bin/npm-debug.log




node
如果/usr/local/bin 下已经存在则会报如上错误,不要再这个文件夹下执行
npm install -g n的命令
执行
cd && npm install -g n
即可