Nodejs 新版安装过程需要安装node-sass模块,开始一直无法安装成功,网上找了很多方法都无法解决,找了很久才找到的解决方案。
1.1 node-sass安装前准备
-
Option 2: Install dependencies and configuration manually
- Install Visual C++ Build Environment: Visual Studio Build Tools (using "Visual C++ build tools" workload) or Visual Studio 2017 Community (using the "Desktop development with C++" workload)
- Install Python 2.7 (
v3.x.x
is not supported), and runnpm config set python python2.7
- Launch cmd,
npm config set msvs_version 2017
1. 安装visual studio 2017 Community版本,Python2.7.18版本(之前装的)
2. 配置环境变量,当来最好也配置一下PYTHON_HOME
npm方式安装node-sass
npm config set python python2.7
npm config set msvs_version 2017
yarn 方式安装node-sass
yarn config set python python2.7
yarn config set msvs_version 2017
3. 安装node-sass模块
# npm
npm install -g node-sass
# yarn
yarn global add node-sass
安装结果如图所示:
如果一下还有问题,建议安装好python和vc++之后,安装一下node-pyp,我中间安装了一下,不知道有没有影响
npm install -g node-gyp
参考文章如下:
nodejs-guidelines/windows-environment.md at master · microsoft/nodejs-guidelines · GitHub