首页 > 解决方案 > 'npm install' 命令未成功执行,引发一些 python 错误

问题描述

我在 Windows 上运行 npm install 来安装节点模块,但是我收到了这个错误,我不知道它是什么,我找不到任何相关的东西。需要一些帮助来解决这个问题。

npm ERR! code 1
npm ERR! path C:\Users\mycomputer\Desktop\project\node_modules\node-libcurl
npm ERR! command failed
npm ERR! command C:\windows\system32\cmd.exe /d /s /c node-gyp rebuild
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@3.8.0
npm ERR! gyp info using node@15.3.0 | win32 | x64
npm ERR! gyp info spawn C:\Users\mycomputer\.windows-build-tools\python27\python.exe
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   'C:\\Users\\mycomputer\\Desktop\\project\\node_modules\\node-gyp\\gyp\\gyp_main.py',
npm ERR! gyp info spawn args   'binding.gyp',
npm ERR! gyp info spawn args   '-f',
npm ERR! gyp info spawn args   'msvs',
npm ERR! gyp info spawn args   '-G',
npm ERR! gyp info spawn args   'msvs_version=2015',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   'C:\\Users\\mycomputer\\Desktop\\project\\node_modules\\node-libcurl\\build\\config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   'C:\\Users\\mycomputer\\Desktop\\project\\node_modules\\node-gyp\\addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   'C:\\Users\\mycomputer\\.node-gyp\\15.3.0\\include\\node\\common.gypi',
npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
npm ERR! gyp info spawn args   '-Dvisibility=default',
npm ERR! gyp info spawn args   '-Dnode_root_dir=C:\\Users\\mycomputer\\.node-gyp\\15.3.0',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=C:\\Users\\mycomputer\\Desktop\\project\\node_modules\\node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=C:\\Users\\mycomputer\\.node-gyp\\15.3.0\\<(target_arch)\\node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=C:\\Users\\mycomputer\\Desktop\\project\\node_modules\\node-libcurl',
npm ERR! gyp info spawn args   '-Dnode_engine=v8',
npm ERR! gyp info spawn args   '--depth=.',
npm ERR! gyp info spawn args   '--no-parallel',
npm ERR! gyp info spawn args   '--generator-output',
npm ERR! gyp info spawn args   'C:\\Users\\mycomputer\\Desktop\\project\\node_modules\\node-libcurl\\build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp: Undefined variable module_name in binding.gyp while trying to load binding.gyp
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: `gyp` failed with exit code: 1
npm ERR! gyp ERR! stack     at ChildProcess.onCpExit (C:\Users\mycomputer\Desktop\project\node_modules\node-gyp\lib\configure.js:345:16)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:376:20)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:277:12)
npm ERR! gyp ERR! System Windows_NT 10.0.17763
npm ERR! gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\mycomputer\\Desktop\\project\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd C:\Users\mycomputer\Desktop\project\node_modules\node-libcurl
npm ERR! gyp ERR! node -v v15.3.0
npm ERR! gyp ERR! node-gyp -v v3.8.0
npm ERR! gyp ERR! not ok

标签: pythonnode.jslaravelnpm

解决方案


没有更多细节很难确定,但看起来问题可能是您的节点模块之一正在使用您的系统 python,而您的系统 python 是版本 2,目前几乎在每个用例中都不受支持(已过时)。我建议尝试在您的系统上安装 python3 并查看是否可以解决问题。


推荐阅读