我正在尝试通过运行以下命令(详细说明at their Tutorial page in their docs来在系统上运行Ionic教程:
sudo ionic start MyIonicProject tutorial
但是,当本教程试图在MyIonicProject中构建node-sass目录时,该教程始终会失败:
gyp verb build dir attempting to create "build" dir: /Users/macdad/MyIonicProject/node_modules/node-sass/build
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/Users/macdad/MyIonicProject/node_modules/node-sass/build'
gyp ERR! System Darwin 17.5.0
gyp ERR! command "/usr/local/bin/node" "/Users/macdad/MyIonicProject/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /Users/macdad/MyIonicProject/node_modules/node-sass
gyp ERR! node -v v8.11.3
gyp ERR! node-gyp -v v3.7.0
gyp ERR! not ok
Build failed with error code: 1
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass@4.9.0 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass@4.9.0 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/macdad/.npm/_logs/2018-08-02T01_58_32_378Z-debug.log
[ERROR] An error occurred while running subprocess npm.
npm i exited with exit code 1.
Re-running this command with the --verbose flag may provide more
information.
尝试在node-sass/build
目录中构建权限时被拒绝-但是如何在尚不存在的目录上设置权限?调用mkdir时,先前的错误输出以下内容:
Error: EACCES: permission denied, mkdir '/Users/imacuser/MyIonicProject/node_modules/node-sass/vendor'
父目录确实具有读/写权限。我在网上看到这个问题的变化形式不同,但找不到任何明确的答案。当您无法运行主要教程时,很难学习框架。感谢您可以在此处提供新手的任何帮助。
编辑:将@ZearaeZ建议的两个命令的完整结果添加到所有包含的项上具有读/写权限之后。构建仍然失败:
MacBook-Pro-6:~ macdad$ sudo npm rebuild node-sass --force
npm WARN using --force I sure hope you know what you are doing.
MacBook-Pro-6:~ macdad$ sudo ionic start MyIonicProject
? ./MyIonicProject exists. Overwrite? Yes
Let's pick the perfect starter template!
Starter templates are ready-to-go Ionic apps that come packed with everything
you need to build your app. To bypass this prompt next time, supply template,
the second argument to ionic start.
? Starter template: tabs
✔ Preparing directory ./MyIonicProject - done!
✔ Downloading and extracting tabs starter - done!
? Integrate your new app with Cordova to target native iOS and Android? Yes
> ionic integrations enable cordova --quiet
✔ Downloading integration cordova - done!
✔ Copying integrations files to project - done!
[OK] Integration cordova added!
Installing dependencies may take several minutes.
✨ IONIC DEVAPP ✨
Speed up development with the Ionic DevApp, our fast, on-device testing mobile app
- Test on iOS and Android without Native SDKs
- LiveReload for instant style and JS updates
--> Install DevApp: https://bitly/ionic-dev-app <--
────────────────────────────────────────────────────────────
> npm i
npm WARN deprecated browserslist@2.11.3: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
> fsevents@1.2.4 install /Users/macdad/MyIonicProject/node_modules/fsevents
> node install
[fsevents] Success: "/Users/macdad/MyIonicProject/node_modules/fsevents/lib/binding/Release/node-v57-darwin-x64/fse.node" already installed
Pass --update-binary to reinstall or --build-from-source to recompile
> node-sass@4.9.0 install /Users/macdad/MyIonicProject/node_modules/node-sass
> node scripts/install.js
Unable to save binary /Users/macdad/MyIonicProject/node_modules/node-sass/vendor/darwin-x64-57 : { Error: EACCES: permission denied, mkdir '/Users/macdad/MyIonicProject/node_modules/node-sass/vendor'
at Object.fs.mkdirSync (fs.js:885:18)
at sync (/Users/macdad/MyIonicProject/node_modules/mkdirp/index.js:71:13)
at Function.sync (/Users/macdad/MyIonicProject/node_modules/mkdirp/index.js:77:24)
at checkAndDownloadBinary (/Users/macdad/MyIonicProject/node_modules/node-sass/scripts/install.js:114:11)
at Object.<anonymous> (/Users/macdad/MyIonicProject/node_modules/node-sass/scripts/install.js:157:1)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
errno: -13,
code: 'EACCES',
syscall: 'mkdir',
path: '/Users/macdad/MyIonicProject/node_modules/node-sass/vendor' }
> uglifyjs-webpack-plugin@0.4.6 postinstall /Users/macdad/MyIonicProject/node_modules/uglifyjs-webpack-plugin
> node lib/post_install.js
> node-sass@4.9.0 postinstall /Users/macdad/MyIonicProject/node_modules/node-sass
> node scripts/build.js
Building: /usr/local/bin/node /Users/macdad/MyIonicProject/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/macdad/MyIonicProject/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 node-gyp@3.8.0
gyp info using node@8.11.3 | 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 "python2" in the PATH
gyp verb `which` failed Error: not found: python2
gyp verb `which` failed at getNotFoundError (/Users/macdad/MyIonicProject/node_modules/which/which.js:13:12)
gyp verb `which` failed at F (/Users/macdad/MyIonicProject/node_modules/which/which.js:68:19)
gyp verb `which` failed at E (/Users/macdad/MyIonicProject/node_modules/which/which.js:80:29)
gyp verb `which` failed at /Users/macdad/MyIonicProject/node_modules/which/which.js:89:16
gyp verb `which` failed at /Users/macdad/MyIonicProject/node_modules/isexe/index.js:42:5
gyp verb `which` failed at /Users/macdad/MyIonicProject/node_modules/isexe/mode.js:8:5
gyp verb `which` failed at FSReqWrap.oncomplete (fs.js:152:21)
gyp verb `which` failed python2 { Error: not found: python2
gyp verb `which` failed at getNotFoundError (/Users/macdad/MyIonicProject/node_modules/which/which.js:13:12)
gyp verb `which` failed at F (/Users/macdad/MyIonicProject/node_modules/which/which.js:68:19)
gyp verb `which` failed at E (/Users/macdad/MyIonicProject/node_modules/which/which.js:80:29)
gyp verb `which` failed at /Users/macdad/MyIonicProject/node_modules/which/which.js:89:16
gyp verb `which` failed at /Users/macdad/MyIonicProject/node_modules/isexe/index.js:42:5
gyp verb `which` failed at /Users/macdad/MyIonicProject/node_modules/isexe/mode.js:8:5
gyp verb `which` failed at FSReqWrap.oncomplete (fs.js:152:21)
gyp verb `which` failed stack: 'Error: not found: python2\n at getNotFoundError (/Users/macdad/MyIonicProject/node_modules/which/which.js:13:12)\n at F (/Users/macdad/MyIonicProject/node_modules/which/which.js:68:19)\n at E (/Users/macdad/MyIonicProject/node_modules/which/which.js:80:29)\n at /Users/macdad/MyIonicProject/node_modules/which/which.js:89:16\n at /Users/macdad/MyIonicProject/node_modules/isexe/index.js:42:5\n at /Users/macdad/MyIonicProject/node_modules/isexe/mode.js:8:5\n at FSReqWrap.oncomplete (fs.js:152:21)',
gyp verb `which` failed code: 'ENOENT' }
gyp verb check python checking for Python executable "python" in the PATH
gyp verb `which` succeeded python /usr/bin/python
gyp verb check python version `/usr/bin/python -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: 8.11.3
gyp verb command install [ '8.11.3' ]
gyp verb install input version string "8.11.3"
gyp verb install installing version: 8.11.3
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: 8.11.3
gyp verb build dir attempting to create "build" dir: /Users/macdad/MyIonicProject/node_modules/node-sass/build
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/Users/macdad/MyIonicProject/node_modules/node-sass/build'
gyp ERR! System Darwin 17.5.0
gyp ERR! command "/usr/local/bin/node" "/Users/macdad/MyIonicProject/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /Users/macdad/MyIonicProject/node_modules/node-sass
gyp ERR! node -v v8.11.3
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
Build failed with error code: 1
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass@4.9.0 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass@4.9.0 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/macdad/.npm/_logs/2018-08-09T13_25_52_106Z-debug.log
[ERROR] An error occurred while running subprocess npm.
npm i exited with exit code 1.
Re-running this command with the --verbose flag may provide more
information.
根据我的建议,我没有该目录的权限是有道理的,因为node-sass
目录是在运行时创建的,并且如果该目录没有自动的读/写权限,则很难如果不存在,请添加它们。
答案 0 :(得分:0)
首先,您需要为用户和组分配权限。
选择磁盘,文件夹或文件,然后选择“文件”>“获取信息”。
单击锁定图标将其解锁,然后输入管理员名称 和密码。
在“名称”列中单击一个用户或组,然后选择一个特权 从弹出菜单中进行设置,并赋予“读写”权限。
单击“操作”弹出菜单(“青蛙”图标),然后选择“应用于 封闭的项目。”
对目录应用权限后,在项目目录中运行此命令。
sudo npm rebuild node-sass --force
它将在您的项目目录中强制重建node-sass。