npm run dev本地项目出错
问题栈
verbose Please try running this command again as root/Administrator. 2729 verbose stack Error: node-sass@3.13.1 postinstall:
node scripts/build.js
2729 verbose stack Exit status 1 2729 verbose stack at EventEmitter.
- 分析发现与node-sass安装相关,一开始以为是网络问题,使用cnpm安装后出现同样问题,百度了下说要编译下发现下面错误。
环境
- OS:Win10
- Python:2.7
- npm -v 5.0.3
- node -v v8.1.3
问题复现--发现与npm rebuild node-sass 出错相关
ERR! stack Error:
C:WindowsMicrosoft.NETFrameworkv4.0.30319msbuild.exe
failed with exit code: 1 stack at ChildProcess.onExit (f:SOFTWARENodejsinstall4.1node_modulesnpmnode_modulesnode-gyplibbuild.js:270:23) gyp ERR! stack at emitTwo (events.js:87:13) gyp ERR! stack at ChildProcess.emit (events.js:172:7) gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12) gyp ERR! System Windows_NT 10.0.10240查看node-gyp的安装教程发现windows环境需要安装Visual C Build Environment 下载安装成功后需要设置使用cmd命令执行:npm config set msvs_version 2015,后面可以欢快的编译npm rebuild node-sass了
后续--node-sass干啥子用的
node-sass是编译sass到css文件,甚至可以通过中间件的方式自动编译。
参考:node-gyp的安装教程