node-sass安装在Jenkins上失败

时间:2015-05-08 18:18:39

标签: node.js jenkins gulp-sass node-sass

我正在尝试设置Jenkins来运行Gulp,但是在尝试安装node-sass(gulp-sass插件的依赖项)时它仍然失败。

问题似乎是节点在安装期间没有找到脚本文件。我验证了脚本确实存在于项目存储库中。当我在服务器上本地提取我的repo并安装它时,安装没有问题。这让我觉得这是与Jenkins相关的环境问题。

这是错误输出:

> node-sass@2.1.1 install /root/.jenkins/jobs/odyssey-frontend/workspace/node_modules/gulp-sass/node_modules/node-sass
> node scripts/install.js

module.js:338
    throw err;
          ^
Error: Cannot find module '/root/.jenkins/jobs/odyssey-frontend/workspace/node_modules/gulp-sass/node_modules/node-sass/scripts/install.js'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:278:25)
    at Function.Module.runMain (module.js:501:10)
    at startup (node.js:129:16)
    at node.js:814:3
npm ERR! Linux 3.14.35-28.38.amzn1.x86_64
npm ERR! argv "node" "/home/ec2-user/.linuxbrew/bin/npm" "install" "--production"
npm ERR! node v0.12.2
npm ERR! npm  v2.7.6
npm ERR! code ELIFECYCLE

npm ERR! node-sass@2.1.1 install: `node scripts/install.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the node-sass@2.1.1 install script 'node scripts/install.js'.
npm ERR! This is most likely a problem with the node-sass package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node scripts/install.js
npm ERR! You can get their info via:
npm ERR!     npm owner ls node-sass
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /root/.jenkins/jobs/odyssey-frontend/workspace/npm-debug.log
module.js:338
    throw err;
          ^
Error: Cannot find module 'gulp-sass'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:278:25)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/root/.jenkins/jobs/odyssey-frontend/workspace/gulpfile.js:11:12)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
Build step 'Execute shell' marked build as failure
Finished: FAILURE

Linux发行版是Amazon Linux AMI,类似Fedora。尝试通过gulp-sass ^ 1.3.3安装node-sass ^ 2.0.1。

我刚刚尝试使用node-sass 3.0.0更新了gulp-sass 2.0.0,但问题仍然存在。

我删除了所有node-sass依赖项,现在它已成功构建。所以它真的只是那个包;所有其他节点包安装成功。

1 个答案:

答案 0 :(得分:2)

我在Github项目中发布了这个问题:https://github.com/sass/node-sass/issues/941#issuecomment-100414516

詹金斯似乎在建造时将所有东西都当作sudo运行。 NPM作为安全功能,不会以sudo的身份运行安装脚本,因此会出错。在安装脚本中添加--unsafe-perm标志可以解决此问题。