node.js - 尝试安装 Windows 构建工具时出错

标签 node.js windows powershell npm discord.js

当我运行npm run windows-intall又名

npm install -g --production windows-build-tools && npm install --production

我收到以下错误。我安装了 python 3.8.2,安装了 Node v14.0.0 x64,将 Powershell 添加到路径 [在环境变量、用户变量/系统变量、PATH 中]。从 VScommunity 下载的 Windows 构建工具。我也下载了Windows dev的通用选项。(还没有重新启动电脑)

这是我得到的错误:

node ./dist/index.js

Downloading python-2.7.15.amd64.msi
[>                                            ] 0.0% (0 B/s)
Downloaded python-2.7.15.amd64.msi. Saved to C:\Users\tariq\.windows-build-tools\python- 
2.7.15.amd64.msi.
Downloading vs_BuildTools.exe
[>                                            ] 0.0% (0 B/s)
Downloaded vs_BuildTools.exe. Saved to C:\Users\tariq\.windows-build-tools\vs_BuildTools.exe.

Starting installation...
events.js:292
throw er; // Unhandled 'error' event
^

Error: spawn powershell.exe ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:268:19)
at onErrorNT (internal/child_process.js:468:16)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
Emitted 'error' event on ChildProcess instance at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:274:12)
at onErrorNT (internal/child_process.js:468:16)
at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'spawn powershell.exe',
  path: 'powershell.exe',
  spawnargs: [
    '-ExecutionPolicy',
    'Bypass',
    '-NoProfile',
    '-NoLogo',
    "& {& 'C:\\Users\\tariq\\AppData\\Roaming\\npm\\node_modules\\windows-build-tools\\ps1\\launch-installer.ps1' -BuildToolsInstallerPath 'C:\\Users\\tariq\\.windows-build-tools' -InstallBuildTools -ExtraBuildToolsParameters '' -PythonInstaller 'python-2.7.15.amd64.msi' -InstallPython -VisualStudioVersion '2017' }"
  ]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="0176686f656e76722c6374686d652c756e6e6d7241342f332f33" rel="noreferrer noopener nofollow">[email protected]</a> postinstall: `node ./dist/index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="9becf2f5fff4ece8b6f9eef2f7ffb6eff4f4f7e8dbaeb5a9b5a9" rel="noreferrer noopener nofollow">[email protected]</a> postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\tariq\AppData\Roaming\npm-cache\_logs\2020-06-05T04_48_32_980Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="660107110315090b03040912265348564856" rel="noreferrer noopener nofollow">[email protected]</a> windows-install: `npm install -g --production windows-build-tools && npm install --production`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="2542445240564a4840474a5165100b150b15" rel="noreferrer noopener nofollow">[email protected]</a> windows-install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\tariq\AppData\Roaming\npm-cache\_logs\2020-06-05T04_48_33_077Z-debug.log

最佳答案

管理员身份运行命令行并尝试以下操作:

npm install --global <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="bdcad4d3d9d2cace90dfc8d4d1d990c9d2d2d1cefd89938d938d" rel="noreferrer noopener nofollow">[email protected]</a>

关于node.js - 尝试安装 Windows 构建工具时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62208689/

相关文章:

c++ - 执行属于其他进程的外部函数

windows - 使用 TerminateProcess 时到底有什么风险?

windows - 如何根据列号分隔固定宽度的文本文件

excel - 在 VS Code 中运行 PowerShell 脚本时出错,但在 PowerShell ISE 中运行良好

javascript - 如何获取数组 Node.js 中的最后一项?

node.js - Socket.IO 中的套接字引用

javascript - Jade 条件菜单

windows - Git:查找大包文件中的最大文件

sql - 有没有一种方法可以在Microsoft SQL Server中使用SQL Server Powershell搜索列?

node.js - 使用 Windows Azure Powershell 设置唯一的部署名称