我正在使用 ionic,我已经通过 git 从 machine1 获取了我的项目到 machine2。
我的 ionic 信息给了我这个:
[ERROR] Error with ./node_modules/@ionic/app-scripts/package.json file: FILE_NOT_FOUND
cli packages: (/usr/local/lib/node_modules)
@ionic/cli-utils : 1.19.0 ionic (Ionic CLI) : 3.19.0
local packages:
@ionic/app-scripts : not installed Ionic Framework : ionic-angular 3.7.1
System:
Node : v8.9.1 npm : 5.5.1 OS : macOS High Sierra
Misc:
backend : pro
当我运行 sudo npm install
时,我得到以下信息:
npm WARN checkPermissions Missing write access to /Users/gerald/Documents/ionic/yesterdayweather/node_modules npm WARN checkPermissions Missing write access to /Users/gerald/Documents/ionic/yesterdayweather/node_modules/@ionic
And then
gyp ERR! configure error gyp ERR! stack Error: EACCES: permission denied, mkdir '/Users/gerald/Documents/ionic/yesterdayweather/node_modules/node-sass/build' gyp ERR! System Darwin 17.2.0 gyp ERR! command "/usr/local/Cellar/node/8.9.1/bin/node" "/Users/gerald/Documents/ionic/yesterdayweather/node_modules/node-gyp/bin/nod e-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library=" gyp ERR! cwd /Users/gerald/Documents/ionic/yesterdayweather/node_modules/node-sass gyp ERR! node -v v8.9.1 gyp ERR! node-gyp -v v3.6.2 gyp ERR! not ok Build failed with error code: 1 npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! node-sass@4.5.3 postinstall:
node scripts/build.js
npm ERR! Exit status 1
我尝试了以下解决方案 1 和 3。
基本上我认为我以 pkg 方式安装了 Node ,所以我删除了它并用 brew 安装了它,所以实际上我不应该有这个问题。
但无论如何我都尝试了选项 1,但它仍然不起作用。
有什么想法吗?
谢谢!
最佳答案
看起来像一个脚本正在尝试写入文件,npm 在以 root 身份运行时默认拒绝。您可以将 --unsafe-perm
放在命令后面以禁用此保护措施。
您也不应该使用 sudo 运行 npm install,因为这不是必需的。 只有在使用 -g
标志全局安装模块时才应该使用 sudo。
2019 年编辑: 不用说,像这样禁用安全防护措施可能非常危险,因为您是在给脚本一个自由通行证,让它可以为所欲为。最好永远不要同时使用 sudo 和 npm,即使是在全局安装模块时也是如此。如果您遇到 npm 的访问问题,请查看 using a version manager或 changing npm's default directory .
关于node.js - sudo npm install 给我拒绝访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47460293/