使用 Node@10.9.0 导入 o​​racledb@3.0.0 时出现 mkdir 权限错误

mkdir permission error while importing oracledb@3.0.0 with Node@10.9.0

当我尝试使用 Node 10.9.0 导入 oracledb@3.0.0 时,出现以下错误,

oracledb Beginning installation
oracledb Verifying installation
oracledb Continuing installation
oracledb ERR! NJS-054: Binary build/Release/oracledb.node was not installed.
oracledb ERR! Failed to install binary package oracledb-v3.0.0-node-abi64-linux-x64.gz
oracledb ERR! EACCES: permission denied, mkdir 'build'
oracledb ERR! For help see https://oracle.github.io/node-oracledb/INSTALL.html#troubleshooting

由于上面的代码似乎是权限问题,我也尝试了 sudo npm i mypck@3.2.0 但它给出了以下错误

sudo: npm: command not found

问题:

如何授予创建目录或执行命令 npm 的权限 sudo 权限,任何帮助将不胜感激。

在 npm 安装中使用 --unsafe-perm=true--allow-root 标志。

npm install -g oracledb@3.0.0 --unsafe-perm=true --allow-root

您可以在此处阅读更多内容:https://docs.npmjs.com/getting-started/fixing-npm-permissions