我有一个错误只有在我尝试安装gulp-sass时才会被抛出。我已经尝试安装其他模块,(如gulp-livereload),它们工作正常。使用npm版本6.0.0。以下是需要它的package.json部分:
"devDependencies": {
"gulp": "^3.9.0",
"gulp-autoprefixer": "^3.0.2",
"gulp-imagemin": "^2.3.0",
"gulp-livereload": "^3.8.0",
"gulp-sass": "^3.0.0",
"gulp-sourcemaps": "^1.5.2",
"gulp-uglifyjs": "^0.6.2",
"imagemin-pngquant": "^4.2.0"
}
这里唯一一个抛出错误的是gulp-sass。这是错误:
gyp info it worked if it ends with ok
gyp verb cli [ '/usr/local/bin/node',
gyp verb cli '/Users/craigbertrand/Sites/devdesktop/drupal-8/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.6.2
gyp info using node@6.11.2 | 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/craigbertrand/Sites/devdesktop/drupal-8/node_modules/which/which.js:13:12)
gyp verb `which` failed at F (/Users/craigbertrand/Sites/devdesktop/drupal-8/node_modules/which/which.js:68:19)
gyp verb `which` failed at E (/Users/craigbertrand/Sites/devdesktop/drupal-8/node_modules/which/which.js:80:29)
gyp verb `which` failed at /Users/craigbertrand/Sites/devdesktop/drupal-8/node_modules/which/which.js:89:16
gyp verb `which` failed at /Users/craigbertrand/Sites/devdesktop/drupal-8/node_modules/isexe/index.js:42:5
gyp verb `which` failed at /Users/craigbertrand/Sites/devdesktop/drupal-8/node_modules/isexe/mode.js:8:5
gyp verb `which` failed at FSReqWrap.oncomplete (fs.js:123:15)
gyp verb `which` failed python2 { Error: not found: python2
gyp verb `which` failed at getNotFoundError (/Users/craigbertrand/Sites/devdesktop/drupal-8/node_modules/which/which.js:13:12)
gyp verb `which` failed at F (/Users/craigbertrand/Sites/devdesktop/drupal-8/node_modules/which/which.js:68:19)
gyp verb `which` failed at E (/Users/craigbertrand/Sites/devdesktop/drupal-8/node_modules/which/which.js:80:29)
gyp verb `which` failed at /Users/craigbertrand/Sites/devdesktop/drupal-8/node_modules/which/which.js:89:16
gyp verb `which` failed at /Users/craigbertrand/Sites/devdesktop/drupal-8/node_modules/isexe/index.js:42:5
gyp verb `which` failed at /Users/craigbertrand/Sites/devdesktop/drupal-8/node_modules/isexe/mode.js:8:5
gyp verb `which` failed at FSReqWrap.oncomplete (fs.js:123:15)
gyp verb `which` failed stack: 'Error: not found: python2\n at getNotFoundError (/Users/craigbertrand/Sites/devdesktop/drupal-8/node_modules/which/which.js:13:12)\n at F (/Users/craigbertrand/Sites/devdesktop/drupal-8/node_modules/which/which.js:68:19)\n at E (/Users/craigbertrand/Sites/devdesktop/drupal-8/node_modules/which/which.js:80:29)\n at /Users/craigbertrand/Sites/devdesktop/drupal-8/node_modules/which/which.js:89:16\n at /Users/craigbertrand/Sites/devdesktop/drupal-8/node_modules/isexe/index.js:42:5\n at /Users/craigbertrand/Sites/devdesktop/drupal-8/node_modules/isexe/mode.js:8:5\n at FSReqWrap.oncomplete (fs.js:123:15)',
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 platform; print(platform.python_version());"` returned: "2.7.10\n"
gyp verb get node dir no --target version specified, falling back to host node version: 6.11.2
gyp verb command install [ '6.11.2' ]
gyp verb install input version string "6.11.2"
gyp verb install installing version: 6.11.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: 6.11.2
gyp verb build dir attempting to create "build" dir: /Users/craigbertrand/Sites/devdesktop/drupal-8/node_modules/node-sass/build
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/Users/craigbertrand/Sites/devdesktop/drupal-8/node_modules/node-sass/build'
gyp ERR! stack at Error (native)
gyp ERR! System Darwin 16.0.0
gyp ERR! command "/usr/local/bin/node" "/Users/craigbertrand/Sites/devdesktop/drupal-8/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /Users/craigbertrand/Sites/devdesktop/drupal-8/node_modules/node-sass
gyp ERR! node -v v6.11.2
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@3.13.1 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass@3.13.1 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
答案 0 :(得分:1)
原来这不是一个权限问题。我所要做的只是添加标志--unsafe-perm=true
。从this github post来看,我认为这是gulp-sass postinstaller本身的一个问题。感谢vishwa指出权限被拒绝错误,我将永远不会发现没有它的帖子。 ;)