Windows 脚本宿主错误:无效字符 - 代码:800A03F6 - 来源:Microsoft JScript 编译错误

问题描述 投票:0回答:5

我在使用 Powershell 和 CMD 时遇到问题。当我尝试在 CMD 中执行 Angular CLI 命令时,如

ng --version
ng new projectName
,我收到此错误;

Windows 脚本宿主错误:无效字符

代码:800A03F6

来源:Microsoft JScript编译错误

img1

windows powershell compiler-errors angular-cli jscript
5个回答
29
投票

更新:

在 Windows 上,.js 文件默认关联到 Windows Scripting Host,因此脚本不会使用 Node 运行。

打开文件资源管理器,找到一个JavaScript文件,打开JavaScript文件的属性,然后“打开方式”,选择Node.js程序文件打开那种文件。

执行此操作后错误应该停止。


18
投票

这就是我解决它的方法:(在 Windows 10 上)

Go to C:\Users\<your_username>\AppData\Roaming\npm\node_modules\@angular\cli\bin

检查 ng.js

右键单击 ng.js 文件并单击“

properties
”选项

您需要使用 node.exe 打开它,因此单击“更改”按钮转到 node js 安装目录和

(example: C:\Program Files\nodejs\node.exe)

选择node.exe

点击确定

它应该像下面这样改变 ng.js 的颜色:

现在尝试 ng -v 和其他 ng 命令


1
投票

安装这个精确的 Angular 版本:

npm -g install @angular/[email protected]

代替最新版本:

npm -g install @angular/cli

修复了上述错误。


0
投票

我在更新到 Angular CLI 13 后遇到了这个确切的问题。尝试了来自其他线程的大量不同建议。这里的解决方案中描述的内容基本上对我有用,但我只想指出一种可能的替代方法来应用不将所有 JS 文件与 node.js 相关联的修复。

在 Windows 上尝试从 package.json 执行脚本会引发 JScript 错误

在你的windows系统环境变量中有一个叫做PATHEXT的变量。如果该值包含

.JS;
,则将其删除。然后重新启动您的 CMD 窗口。


0
投票

确保您配置了正确的路径变量,如下所示

转到您的系统变量设置

path variable snapshot

确保您将所有这些提到的作为路径的一部分 C:\Users\AppData\Roaming 下午 ode_modules@angula

© www.soinside.com 2019 - 2024. All rights reserved.