node-sass 在 jenkins 中因为权限无法安装的问题

这个问题发现了好多次了,今天应该是找到了正确的解决方式:

我使用 whoami 输出执行命令的用户是 root,但是 node 执行安装node-sass时调用了 mkdir 以及调用 binding.node 没有权限。然后试了一下使用 sudo 来执行 rebuild node-sass ,就成功了。这是我的日志:

+ npm install
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

up to date in 10.108s
+ whoami
root
+ sudo npm rebuild node-sass --save-dev
> node-sass@4.9.0 install /var/lib/jenkins/workspace/【测试环境】XXX-后台网页/node_modules/node-sass
> node scripts/install.js

Downloading binary from https://github.com/sass/node-sass/releases/download/v4.9.0/linux-x64-57_binding.node
Download complete
Binary saved to /var/lib/jenkins/workspace/【测试环境】XXX-后台网页/node_modules/node-sass/vendor/linux-x64-57/binding.node
Caching binary to /root/.npm/node-sass/4.9.0/linux-x64-57_binding.node

> node-sass@4.9.0 postinstall /var/lib/jenkins/workspace/【测试环境】XXX-后台网页/node_modules/node-sass
> node scripts/build.js

Binary found at /var/lib/jenkins/workspace/【测试环境】XXX-后台网页/node_modules/node-sass/vendor/linux-x64-57/binding.node
Testing binary
Binary is fine
node-sass@4.9.0 /var/lib/jenkins/workspace/【测试环境】XXX-后台网页/node_modules/node-sass
+ npm run build:itl

> base4j-ui@1.0.1 build:itl /var/lib/jenkins/workspace/【测试环境】XXX-后台网页
> cross-env NODE_ENV=production node build/build_xxx.js

production
Starting to optimize CSS...

 

Leave a Comment

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据