【发布时间】:2022-01-15 07:15:24
【问题描述】:
在过去的几天里,我一直在尝试在我的 Windows 10 虚拟机上安装 node/npm,但我尝试了所有我发现的方法,但没有成功。
我按照node-gyp setup instructions for Windows 说要安装Python3.7。 npm microsoft-build-tools 现在已弃用并使用 microsoft 安装程序(我使用过)安装。我还通过 Visual Studio 安装了该工具,并尝试npm config set msvs_version 2015 -g 尝试 2015/2017。我有node -v v16.13.1、node-gyp -v v8.4.1、npm 8.2。每次我尝试npm install 时,我都会不断得到相同的堆栈跟踪
C:\Users\dperrone1\Desktop\project\node_modules\libxslt
npm ERR! command failed
LINK : fatal error LNK1181: cannot open input file 'C:\Users\dperrone1\Desktop\project\node_modules\node1-libxmljsmt-myh\build\Release\xmljs-myh.lib' [C:\Users\dperrone1\Desktop\project\node_modules\libxslt\build\node-libxslt.vcxproj]
npm ERR! gyp info find Python using Python version 3.10.1 found
gyp info find VS using VS2017 (15.9.28307.1745) found at:
npm ERR! gyp info find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools"
npm ERR! gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe` failed with exit code: 1
"C:\\Users\\dperrone1\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd C:\Users\dperrone1\Desktop\project\node_modules\libxslt
围绕 npm 重建/删除 node_modules 的解决方案都不起作用,因为在 npm install 失败后,它会清除它添加的 node_modules。请问有什么建议吗?无论如何要使用替代库?
已修复:问题原来不是构建工具本身,而是构建工具试图构建的模块。我删除了依赖关系 libxslt、xml、xml-parser、xml2js 和 xmltojson。核心问题是libxslt,出于某种原因,npm 试图找到该模块不存在的分支。我在尝试在 WSL 上安装它时遇到了同样的问题,但是删除这些软件包可以解决所有问题
【问题讨论】:
标签: python node.js windows npm node-gyp