求助,使用vue时安装node-sass报错

beimyy beimyy 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
使用vue时安装node-sass报错

在服务器上部署vue项目时,node-sass安装不了,导致项目不能build,特来此求助.

操作系统是centos7
```shell
[root@vm172-31-48-7 apps]# uname -sr
Linux 3.10.0-693.21.1.el7.x86_64
```

node版本
```shell
[root@vm172-31-48-7 vuetest]# node -v
v8.11.3
[root@vm172-31-48-7 vuetest]# npm -v
6.1.0

```
通过vue-cli搭建了项目
```shell
vue init webpack vuetest
cd vuetest
npm install
```
到这里一切正常.
安装sass-loader
```shell
[root@vm172-31-48-7 vuetest]# npm install sass-loader --save-dev --registry=https://registry.npm.taobao.org
```
安装成功,然后安装node-sass失败
```shell
[root@vm172-31-48-7 vuetest]# npm install node-sass --save-dev --registry=https://registry.npm.taobao.org

> node-sass@4.9.0 install /apps/vuetest/node_modules/node-sass
> node scripts/install.js

Unable to save binary /apps/vuetest/node_modules/node-sass/vendor/linux-x64-57 : { Error: EACCES: permission denied, mkdir '/apps/vuetest/node_modules/node-sass/vendor'
at Object.fs.mkdirSync (fs.js:885:18)
at sync (/apps/vuetest/node_modules/mkdirp/index.js:71:13)
at Function.sync (/apps/vuetest/node_modules/mkdirp/index.js:77:24)
at checkAndDownloadBinary (/apps/vuetest/node_modules/node-sass/scripts/install.js:114:11)
at Object.<anonymous> (/apps/vuetest/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: '/apps/vuetest/node_modules/node-sass/vendor' }

> node-sass@4.9.0 postinstall /apps/vuetest/node_modules/node-sass
> node scripts/build.js

Building: /usr/local/node/bin/node /apps/vuetest/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/node/bin/node',
gyp verb cli '/apps/vuetest/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.7.0
gyp info using node@8.11.3 | linux | 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` succeeded python2 /usr/bin/python2
gyp verb check python version `/usr/bin/python2 -c "import platform; print(platform.python_version());"` returned: "2.7.5\n"
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: /apps/vuetest/node_modules/node-sass/build
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/apps/vuetest/node_modules/node-sass/build'
gyp ERR! System Linux 3.10.0-693.21.1.el7.x86_64
gyp ERR! command "/usr/local/node/bin/node" "/apps/vuetest/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /apps/vuetest/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 WARN ajv-keywords@3.2.0 requires a peer of ajv@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

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! /root/.npm/_logs/2018-06-27T16_32_20_050Z-debug.log
```

package.json
```json
{
"name": "vuetest",
"version": "1.0.0",
"description": "A Vue.js project",
"author": "",
"private": true,
"scripts": {
"dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",
"start": "npm run dev",
"build": "node build/build.js"
},
"dependencies": {
"vue": "^2.5.2",
"vue-router": "^3.0.1"
},
"devDependencies": {
"autoprefixer": "^7.1.2",
"babel-core": "^6.22.1",
"babel-helper-vue-jsx-merge-props": "^2.0.3",
"babel-loader": "^7.1.1",
"babel-plugin-syntax-jsx": "^6.18.0",
"babel-plugin-transform-runtime": "^6.22.0",
"babel-plugin-transform-vue-jsx": "^3.5.0",
"babel-preset-env": "^1.3.2",
"babel-preset-stage-2": "^6.22.0",
"chalk": "^2.0.1",
"copy-webpack-plugin": "^4.0.1",
"css-loader": "^0.28.0",
"extract-text-webpack-plugin": "^3.0.0",
"file-loader": "^1.1.4",
"friendly-errors-webpack-plugin": "^1.6.1",
"html-webpack-plugin": "^2.30.1",
"node-notifier": "^5.1.2",
"optimize-css-assets-webpack-plugin": "^3.2.0",
"ora": "^1.2.0",
"portfinder": "^1.0.13",
"postcss-import": "^11.0.0",
"postcss-loader": "^2.0.8",
"postcss-url": "^7.2.1",
"rimraf": "^2.6.0",
"sass-loader": "^7.0.3",
"semver": "^5.3.0",
"shelljs": "^0.7.6",
"uglifyjs-webpack-plugin": "^1.1.1",
"url-loader": "^0.5.8",
"vue-loader": "^13.3.0",
"vue-style-loader": "^3.0.1",
"vue-template-compiler": "^2.5.2",
"webpack": "^3.6.0",
"webpack-bundle-analyzer": "^2.9.0",
"webpack-dev-server": "^2.9.1",
"webpack-merge": "^4.1.0"
},
"engines": {
"node": ">= 6.0.0",
"npm": ">= 3.0.0"
},
"browserslist": [
"> 1%",
"last 2 versions",
"not ie <= 8"
]
}
```
...全文

相关推荐

window环境下npm install node-sass报错的解决方法

最近准备想用vue-cli初始化一个项目,需要sass-loader编译; 发现window下npm install node-sass和sass-loader一直报错, window 命令行中提示我全局安装 node-gyp ,有些提示好像是本地找不到python, 于是我按照提示安装node-gyp node-gyp是一个用Node.js编写的跨平台命令行工具,用于编译Node.js的本地插件模块。 node-gyp node-gyp官方网址  https://www.npmjs.com/package/node-gyp 命令行代码 npm install -g node-gyp 安装

weixin_38665449

vue使用Sass时报错问题的解决方法

主要介绍了vue使用Sass时报错问题的解决方法,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下

weixin_38564503

详解在vue-cli项目中安装node-sass

1,使用save会在package.json中自动添加。 npm install node-sass --save npm install sass-loader --save 2,通常使用npm安装会出现以下报错,安装失败。(网路问题) 3,可以通过淘宝的npm镜像安装node-sass,解决以上问题。 npm install -g cnpm --registry=https://registry.npm.taobao.org (安装淘宝镜像) cnpm install node-sass --save (使用淘宝镜像安装node-sass)

weixin_38633967

详解如何在vue中使用sass

本篇文章主要介绍了详解如何在vue中使用sass,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧

weixin_38598213

vue安装和使用scss及sass与scss的区别详解

主要介绍了vue安装和使用教程,用了很久css预编译器,但是一直不太清楚到底用的sass还是scss,直到有天被问住了有点尴尬,感兴趣的朋友一起看看吧

weixin_38618540
评论 7
收藏 已收藏
分享
返回顶部
beimyy
JavaScript 87,984 成员 224,681 内容