如何使用Windows PowerShell PackageManager(OneGet)安装Node.js?

时间:2019-02-18 02:02:14

标签: node.js windows powershell oneget windows-package-manager

我尝试了Install-Package nodejs,它似乎已经做了一些事情:

PS C:\WINDOWS\system32> Install-Package nodejs

The package(s) come(s) from a package source that is not marked as trusted.
Are you sure you want to install software from 'chocolatey'?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"): y

Name                           Version          Source           Summary
----                           -------          ------           -------
nodejs.install                 11.10.0          chocolatey       Node JS - Evented I/O for v8 JavaScript.
nodejs                         11.10.0          chocolatey       Node JS - Evented I/O for v8 JavaScript.

然后,当我尝试运行node命令时,它将失败:

PS C:\WINDOWS\system32> node
node : The term 'node' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ node
+ ~~~~
    + CategoryInfo          : ObjectNotFound: (node:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

如何使用PackageManager正确执行操作,以便该命令可用?

不确定是否与其他问题相关:Chocolaty packages not installing via OneGet/PackageManagement in Windows 10?

正如另一个问题所暗示的那样,我尝试设置Set-ExecutionPolicy Unrestricted,卸载并重新安装nodejs,但结果是相同的。

我确实看到安装后存在以下文件:

C:\Chocolatey\lib\nodejs.11.10.0\nodejs.11.10.0.nupkg
C:\Chocolatey\lib\nodejs.install.11.10.0.nupkg\nodejs.install.11.10.0.nupkg
C:\Chocolatey\lib\nodejs.install.11.10.0.nupkg\nodejs.install.11.10.0.nupkg
C:\Chocolatey\lib\nodejs.install.11.10.0.nupkg\nodejs.install.11.10.0.nupkg\legal\LICENSE.txt
C:\Chocolatey\lib\nodejs.install.11.10.0.nupkg\nodejs.install.11.10.0.nupkg\legal\VERIFICATION.txt
C:\Chocolatey\lib\nodejs.install.11.10.0.nupkg\nodejs.install.11.10.0.nupkg\tools\chocolateyInstall.ps1
C:\Chocolatey\lib\nodejs.install.11.10.0.nupkg\nodejs.install.11.10.0.nupkg\tools\node-v11.10.0-x64.msi
C:\Chocolatey\lib\nodejs.install.11.10.0.nupkg\nodejs.install.11.10.0.nupkg\tools\node-v11.10.0-x86.msi

这让我觉得也许是希望我以后手动运行安装程序?

我的目标是仅通过脚本在新Windows机器上安装所需的任何东西,而无需使用GUI手动下载/安装所有东西。

0 个答案:

没有答案