操作系统:MacOS Mojave 10.14.2
离子:4.10.3节点:10.15.2 npm:6.4.1
当我试图创建一个新项目时,离子或npm失败:
在给出命令时:
sudo ionic start testApp blank --type = ionic-angular
> [email protected] postinstall /Users/international/Public/testApp/node_modules/node-sass
> node scripts/build.js
Building: /usr/local/bin/node /Users/international/Public/testApp/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
gyp info it worked if it ends with ok
gyp verb cli [ '/usr/local/bin/node',
gyp verb cli '/Users/international/Public/testApp/node_modules/node-gyp/bin/node-gyp.js',
gyp verb cli 'rebuild',
gyp verb cli '--verbose',
gyp verb cli '--libsass_ext=',
gyp verb cli '--libsass_cflags=',
gyp verb cli '--libsass_ldflags=',
gyp verb cli '--libsass_library=' ]
gyp info using [email protected]
gyp info using [email protected] | darwin | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb check python checking for Python executable "/usr/bin/python2.7" in the PATH
gyp verb `which` succeeded /usr/bin/python2.7 /usr/bin/python2.7
gyp verb check python version `/usr/bin/python2.7 -c "import sys; print "2.7.10
gyp verb check python version .%s.%s" % sys.version_info[:3];"` returned: %j
gyp verb get node dir no --target version specified, falling back to host node version: 10.15.2
gyp verb command install [ '10.15.2' ]
gyp verb install input version string "10.15.2"
gyp verb install installing version: 10.15.2
gyp verb install --ensure was passed, so won't reinstall if already installed
gyp verb install version is already installed, need to check "installVersion"
gyp verb got "installVersion" 9
gyp verb needs "installVersion" 9
gyp verb install version is good
gyp verb get node dir target node version installed: 10.15.2
gyp verb build dir attempting to create "build" dir: /Users/international/Public/testApp/node_modules/node-sass/build
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/Users/international/Public/testApp/node_modules/node-sass/build'
gyp ERR! System Darwin 18.2.0
gyp ERR! command "/usr/local/bin/node" "/Users/international/Public/testApp/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /Users/international/Public/testApp/node_modules/node-sass
gyp ERR! node -v v10.15.2
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
Build failed with error code: 1
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] install: `node install`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/international/.npm/_logs/2019-03-05T09_26_51_725Z-debug.log
[ERROR] An error occurred while running subprocess npm.
npm i exited with exit code 1.
在某处您会发现“权限被拒绝”为错误但在我的命令中我使用sudo作为前缀。
我不知道发生了什么,我花了很多时间才找到解决方案。我也是MacOS的新用户
您需要更改node_modules
文件夹的所有权。
要更改文件夹的权限,请在终端中执行以下操作:
sudo chown -R root:YOUR_USERNAME /Users/international/Public/testApp/node_modules/
sudo chmod -R 775 /Users/international/Public/testApp/node_modules/
如果这不起作用,您可以递归设置文件夹的权限,如下所示:
sudo chmod 777 -R /Users/international/Public/testApp/