npm版本8.11.4
当安装项目依赖npm i的时候出现
Error: Can't find Python executable "python", you can set the PYTHON env variable.
是因为node-sass安装问题,重新装一下node-sass可解决
在安装node-sass的时候遇到如下问题
gyp ERR! stack Error: ENOENT: no such file or directory, mkdir 'C:\Users\admin\AppData\Local\node-gyp\Cache\8.11.4'
这是由于走了本地编译,本地没有python,走淘宝镜像安装 将npm镜像换成淘宝最新镜像,注意一定是淘宝最新镜像:执行npm config set registry https://registry.npmmirror.com
以上最好可以在npmrc文件里面,用vscode打开
将里面的内容全部替换为
# mirror config sharp_binary_host = https://npmmirror.com/mirrors/sharp sharp_libvips_binary_host = https://npmmirror.com/mirrors/sharp-libvips profiler_binary_host_mirror = https://npmmirror.com/mirrors/node-inspector/ fse_binary_host_mirror = https://npmmirror.com/mirrors/fsevents node_sqlite3_binary_host_mirror = https://npmmirror.com/mirrors sqlite3_binary_host_mirror = https://npmmirror.com/mirrors sqlite3_binary_site = https://npmmirror.com/mirrors/sqlite3 sass_binary_site = https://npmmirror.com/mirrors/node-sass electron_mirror = https://npmmirror.com/mirrors/electron/ puppeteer_download_host = https://npmmirror.com/mirrors chromedriver_cdnurl = https://npmmirror.com/mirrors/chromedriver operadriver_cdnurl = https://npmmirror.com/mirrors/operadriver phantomjs_cdnurl = https://npmmirror.com/mirrors/phantomjs python_mirror = https://npmmirror.com/mirrors/python registry = https://registry.npmmirror.com disturl = https://npmmirror.com/dist
然后安装对应版本号的windows-build-tools,执行命令npm install --global windows-build-tools@4.0.0安装完python,部分失败先不管
然后安装对应版本的node-sass,先将之前的node-modules全部删掉再安装【注意一定都要是对应版本,因为npm版本太低了】
执行npm install node-sass@4.5.3 --save-dev 安装node-sass成功了
执行完之后执行npm i还是报错,发现是因为项目里面package-lock.json里面node-sass写了1.13.1版本,将node-sass版本号全部改为4.5.3
然后执行npm i 成功