npm安装本地软件包时出错。 npm用于全局安装本地软件包

时间:2020-10-02 03:42:06

标签: node.js npm node-pre-gyp

我想使用npm安装本地npm软件包。

我希望软件包安装到全局。

node-bluetooth-hci-socket有一些nodev10错误:所以我是同伴:

https://github.com/noble/node-bluetooth-hci-socket/issues/84

更改源代码并安装。

命令npm install将成功。

root@raspberrypi:~/node-bluetooth-hci-socket# npm run install

...
> node-pre-gyp install --fallback-to-build

[bluetooth-hci-socket] Success: "/root/node-bluetooth-hci-socket/lib/binding/binding.node" already installed

但是问题是当我尝试全局安装时。

root@raspberrypi:~/node-bluetooth-hci-socket# npm install . -g

> bluetooth-hci-socket@0.5.2 preinstall /usr/local/lib/node_modules/bluetooth-hci-socket
> npm install node-pre-gyp

Error: EACCES: permission denied, scandir '/root/node-bluetooth-hci-socket'

> bluetooth-hci-socket@0.5.2 install /usr/local/lib/node_modules/bluetooth-hci-socket
> node-pre-gyp install --fallback-to-build

fs.js:114
    throw err;
    ^

Error: EACCES: permission denied, open '/root/node-bluetooth-hci-socket/package.json'
...

我已经使用root用户,但是我不知道为什么在尝试全局安装时仍然拒绝权限。

我想知道如何全局安装并修复此错误。

0 个答案:

没有答案