一、背景介绍:
在解决完npm超时问题后,执行指令npm install,会报找不到Python的错误


二、问题分析
因此考虑到node-gyp是否已经安装,然后控制台输入查看node-gyp命令:node-gyp list,结果如下:

果然是在解决上个npm超时问题时把node-gyp给删掉了,知道了原因接下来就容易多了,直接重新安装node-gyp。
三、问题解决
前面我的随笔有详细介绍node-gyp的安装步骤:【https://www.cnblogs.com/wangyuxue/p/11218113.html】
1、一键安装命令(其中包括Python):npm install --global --production windows-build-tools,结果如下:

2、node-gyp安装命令:npm install -g node-gyp,结果如下:

3、安装成功的查看指令:node-gyp list,结果:

4、 (1)再次执行命令npm install,还是报上面的错误,看了一下错误内容,让你设置Python环境变量,如何设置呢?
(2)环境变量设置参考【https://blog.csdn.net/qq_31672775/article/details/78164794】。
(3)在设置环境变量之前需要知道Python2.7安装目录,一般安装在C盘的【Program Files】或者【Program Files(x86)】,如果找不到,则需要重新安装Python2.7,官网【https://www.python.org/downloads/】。
(4)设置环境变量:我的电脑->右击->属性->高级系统设置->高级->环境变量->用户变量(PATH->编辑->在路径后加英文分号,粘贴Python2.7路径->一路完成)->系统变量(Path->编辑->在路径后加英文分号,粘贴Python2.7路径->一路完成)。
5、在控制台输入npm install命令,发现上述错误不见了~
|