“D:\HBuilderX\plugins\npm\npm” install –save –registry=h
ttps://registry.npmmirror.com
所在位置 行:1 字符: 32
+ “D:\HBuilderX\plugins\npm\npm” install –save –registry=https://regi …
+ ~~~~~~~
+ ~~~~~~~
表达式或语句中包含意外的标记“install”。
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnexpectedToken
你的命令在 PowerShell 运行时出现 ParserError
,原因是 PowerShell 把 https://
解析成了错误的语法。
解决方案
方法 1:在 https://
之前加 --%
“D:\HBuilderX\plugins\npm\npm” –% install –save –registry=https://registry.npmmirror.com
--%
让 PowerShell 忽略后面的特殊字符(如 https://
),这样就不会报 ParserError
了。
方法 2:用 cmd
运行
cmd /c “D:\HBuilderX\plugins\npm\npm install –save –registry=https://registry.npmmirror.com”
cmd /c
让命令在 CMD 中执行,避免 PowerShell 解析错误。
方法 3:换 CMD 直接运行
你也可以直接打开 CMD,然后运行
如果 CMD 可以执行,但 PowerShell 仍然报错,说明只是 PowerShell 解析问题。