尝试在 VScode 中通过 npm 安装 Parcel 时,出现以下错误。
npm ERR! code 1
npm ERR! path C:\Users\user-id\ws-js-001\node_modules\@parcel\watcher
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c node-gyp-build
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | win32 | x64
npm ERR! gyp ERR! find Python
npm ERR! gyp ERR! find Python checking Python explicitly set from command line or npm configuration
npm ERR! gyp ERR! find Python - "--python=" or "npm config get python" is "python3.10"
npm ERR! gyp ERR! find Python - "python3.10" is not in PATH or produced an error
npm ERR! gyp ERR! find Python checking Python explicitly set from environment variable PYTHON
npm ERR! gyp ERR! find Python - process.env.PYTHON is "C:\Users\user-id\AppData\Local\Programs\Python\Python310\python.exe"
npm ERR! gyp ERR! find Python - "C:\Users\user-id\AppData\Local\Programs\Python\Python310\python.exe" is not in PATH
or produced an error
配置文件中的配置值为
C:\Users\user-id\ws-js-001> npm config get python
python3.10
环境变量 python 也设置为
C:\Windows\system32>set PYTHON
PYTHON=C:\Users\user-id\AppData\Local\Programs\Python\Python310\python.exe
您能否帮助我进行解决此问题所需的更改。
@parcel/watcher
是一个原生 C++ 包,parcel
用于监视项目的更改并在看到更改时重新构建。为了在底层创建本机 C++ 和节点之间的绑定,它使用 node-gyp-build
。根据node-gyp
文档:
node-gyp 要求您安装了兼容版本的 Python,其中之一:v3.6、v3.7、v3.8 或 v3.9。
因此我建议将您的 python 版本升级到受支持的版本之一。
(旁注 - 看起来
@parcel/watcher
包含针对多个平台的预构建二进制文件,包括 windows-x64
,因此,如果您在这些平台上使用该软件包,则无需使用 node-gyp
构建任何内容系统。我的猜测是您使用的是 32 位 Windows,因为这似乎不包括在内 - 对吗?)
尝试使用
npm i --ignore-scripts
或将 ignore-scripts=true
添加到 .npmrc