我试过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 installed 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 手动下载/安装它们。