使用npm install报错npm ERR! gyp verb find Python Python is not set from command line or npm configuratio

npm ERR! code 1
npm ERR! path E:\MyProgram\stars-master\web\node_modules\node-sass
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c node scripts/build.js
npm ERR! Building: E:\BaiduDownload\nodejs\node.exe E:\MyProgram\stars-master\web\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp verb cli [
npm ERR! gyp verb cli   'E:\\BaiduDownload\\nodejs\\node.exe',
npm ERR! gyp verb cli   'E:\\MyProgram\\stars-master\\web\\node_modules\\node-gyp\\bin\\node-gyp.js',
npm ERR! gyp verb cli   'rebuild',
npm ERR! gyp verb cli   '--verbose',
npm ERR! gyp verb cli   '--libsass_ext=',
npm ERR! gyp verb cli   '--libsass_cflags=',
npm ERR! gyp verb cli   '--libsass_ldflags=',
npm ERR! gyp verb cli   '--libsass_library='
npm ERR! gyp verb cli ]
npm ERR! gyp info using node-gyp@8.4.1
npm ERR! gyp info using node@20.10.0 | win32 | x64
npm ERR! gyp verb command rebuild []
npm ERR! gyp verb command clean []
npm ERR! gyp verb clean removing "build" directory
npm ERR! gyp verb command configure []
npm ERR! gyp verb find Python Python is not set from command line or npm configuration
npm ERR! gyp verb find Python Python is not set from environment variable PYTHON
npm ERR! gyp verb find Python checking if "python3" can be used
npm ERR! gyp verb find Python - executing "python3" to get executable path
npm ERR! gyp verb find Python - "python3" is not in PATH or produced an error
npm ERR! gyp verb find Python checking if "python" can be used
npm ERR! gyp verb find Python - executing "python" to get executable path
npm ERR! gyp verb find Python - executable path is "E:\BaiduDownload\Python\python.exe"
npm ERR! gyp verb find Python - executing "E:\BaiduDownload\Python\python.exe" to get version
npm ERR! gyp verb find Python - version is "3.8.5"
npm ERR! gyp info find Python using Python version 3.8.5 found at "E:\BaiduDownload\Python\python.exe"
npm ERR! gyp verb get node dir no --target version specified, falling back to host node version: 20.10.0
npm ERR! gyp verb command install [ '20.10.0' ]
npm ERR! gyp verb install input version string "20.10.0"
npm ERR! gyp verb install installing version: 20.10.0
npm ERR! gyp verb install --ensure was passed, so won't reinstall if already installed
npm ERR! gyp verb install version is already installed, need to check "installVersion"
npm ERR! gyp verb got "installVersion" 9
npm ERR! gyp verb needs "installVersion" 9
npm ERR! gyp verb install version is good
npm ERR! gyp verb get node dir target node version installed: 20.10.0
npm ERR! gyp verb build dir attempting to create "build" dir: E:\MyProgram\stars-master\web\node_modules\node-sass\build
npm ERR! gyp verb build dir "build" dir needed to be created? Yes
npm ERR! gyp verb find VS msvs_version not set from command line or npm config
npm ERR! gyp verb find VS VCINSTALLDIR not set, not running in VS Command Prompt
npm ERR! gyp verb find VS could not use PowerShell to find Visual Studio 2017 or newer, try re-running with '--loglevel silly' for more details
npm ERR! gyp verb find VS looking for Visual Studio 2015
npm ERR! gyp verb find VS - not found
npm ERR! gyp verb find VS not looking for VS2013 as it is only supported up to Node.js 8
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! find VS msvs_version not set from command line or npm config
npm ERR! gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
npm ERR! gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer, try re-running with '--loglevel silly' for more details
npm ERR! gyp ERR! find VS looking for Visual Studio 2015
npm ERR! gyp ERR! find VS - not found
npm ERR! gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! find VS **************************************************************
npm ERR! gyp ERR! find VS You need to install the latest version of Visual Studio
npm ERR! gyp ERR! find VS including the "Desktop development with C++" workload.
npm ERR! gyp ERR! find VS For more information consult the documentation at:
npm ERR! gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
npm ERR! gyp ERR! find VS **************************************************************
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: Could not find any Visual Studio installation to use
npm ERR! gyp ERR! stack     at VisualStudioFinder.fail (E:\MyProgram\stars-master\web\node_modules\node-gyp\lib\find-visualstudio.js:122:47)
npm ERR! gyp ERR! stack     at E:\MyProgram\stars-master\web\node_modules\node-gyp\lib\find-visualstudio.js:75:16
npm ERR! gyp ERR! stack     at VisualStudioFinder.findVisualStudio2013 (E:\MyProgram\stars-master\web\node_modules\node-gyp\lib\find-visualstudio.js:363:14)
npm ERR! gyp ERR! stack     at E:\MyProgram\stars-master\web\node_modules\node-gyp\lib\find-visualstudio.js:71:14
npm ERR! gyp ERR! stack     at E:\MyProgram\stars-master\web\node_modules\node-gyp\lib\find-visualstudio.js:384:16
npm ERR! gyp ERR! stack     at E:\MyProgram\stars-master\web\node_modules\node-gyp\lib\util.js:54:7
npm ERR! gyp ERR! stack     at E:\MyProgram\stars-master\web\node_modules\node-gyp\lib\util.js:33:16
npm ERR! gyp ERR! stack     at ChildProcess.exithandler (node:child_process:430:5)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:514:28)
npm ERR! gyp ERR! stack     at maybeClose (node:internal/child_process:1105:16)
npm ERR! gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:305:5)
npm ERR! gyp ERR! System Windows_NT 10.0.19045
npm ERR! gyp ERR! command "E:\\BaiduDownload\\nodejs\\node.exe" "E:\\MyProgram\\stars-master\\web\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
npm ERR! gyp ERR! cwd E:\MyProgram\stars-master\web\node_modules\node-sass
npm ERR! gyp ERR! node -v v20.10.0
npm ERR! gyp ERR! node-gyp -v v8.4.1
npm ERR! gyp ERR! not ok
npm ERR! Build failed with error code: 1

npm ERR! A complete log of this run can be found in: E:\BaiduDownload\nodejs\node_cache\_logs\2023-12-11T03_32_24_428Z-debug-0.log

使用npm install报了一大堆错误,一个搞后端的也要学会折腾前端啊。

解决方法:

这个错误是由于在构建 node-sass 模块时
node-sass 是 C++ 版本,可以考虑使用 sass,它是 node-sass 的纯 JavaScript 实现。

首先卸载 node-sass

npm uninstall node-sass

然后安装 sass

npm install sass

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
### 回答1: 这个错误是由于在安装某些 npm 包时,需要使用 Python 解释器来编译一些本地模块,但是无法找到可用的 Python 解释器。具体来说,它在尝试执行命令 "gyp verb check python" 时发生错误,该命令用于检查 Python 解释器是否可用。 为了解决这个问题,你可以尝试以下几种方法: 1. 安装 Python 解释器。你可以从 Python 官方网站(https://www.python.org/downloads/)下载并安装 Python。 2. 将 Python 加入系统环境变量。在 Windows 操作系统中,你可以将 Python 的安装路径添加到 PATH 环境变量中。在 macOS 或 Linux 操作系统中,你可以将 Python 的可执行文件路径添加到 PATH 环境变量中。 3. 使用 nvm 切换到其他版本的 Node.js。有时,此错误可能是由于 Node.js 版本与所需的 Python 版本不兼容造成的。你可以使用 nvm(Node Version Manager)来切换到另一个 Node.js 版本,以查看是否解决了问题。 希望这些方法能够帮助你解决问题。如果还有问题,请随时向我提问。 ### 回答2: 这个错误是因为你在使用npm安装某个依赖包的时候,该包需要依赖node-gyp模块进行编译,而node-gyp则需要依赖Python2.x来实现编译过程。因此,npm会检查你的电脑环境中是否已经安装了Python,并且会查找Python可执行文件路径中是否存在名为“python2”的文件。 如果你的电脑中没有安装Python或者没有设置Python的可执行文件路径,就会报出这个错误。因此,解决这个问题的方法就是安装Python2.x并将其可执行文件所在路径添加到环境变量中。 首先,你可以在Python官网(https://www.python.org/)下载Python2.x的安装包,并进行安装。安装过程中需要注意勾选“Add Python to PATH”选项,这样Python的可执行文件路径就会被添加到环境变量中。 安装完成后,你需要重新启动终端或者在终端中重新加载环境变量,才能使路径生效。之后,你再次使用npm安装需要node-gyp编译的依赖包,就不会再出现这个错误了。 ### 回答3: 这里的npm err! gyp verb check python checking for python executable "python2" in the path是指在使用npm安装或构建某些包时,出现了python执行文件的检测问题。该问题通常是由于缺少Python环境引起的。 npm是一个JavaScript软件包管理器,但是,一些组件可能需要在构建过程中使用Python。要解决这个问题,需要安装Python环境,并确保python2可执行文件在系统环境变量的路径中。 在Windows系统中,安装Python是很简单的。您可以从Python官方网站下载适合您的操作系统的Python版本安装程序,运行安装程序并按照指示完成安装。 在Linux和macOS系统中,默认情况下已经安装了Python。您可以通过在命令行终端中键入“python --version”命令来检查Python的版本。如果Python未安装或版本过旧,则可以通过软件包管理器或从Python官方网站下载可执行文件进行安装。 当Python环境安装完成后,需要确保python2可执行文件已添加到系统环境变量中。在Windows系统中,您可以进入“控制面板”>“系统和安全”>“系统”>“高级系统设置”>“环境变量”,然后找到系统变量“Path”,添加Python所在路径即可。在Linux和macOS系统中,可以将Python路径添加到.bashrc文件中。 总之,通过安装Python环境并将python2可执行文件添加到系统环境变量中,就可以解决npm err! gyp verb check python checking for python executable "python2" in the path的问题。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值