Reputation: 583
I'm having an issue with Powershell and CMD. When I try to execute Angular CLI commands in CMD like ng --version
or ng new projectName
, I get this error;
Windows Script Host Error: Invalid character
Code: 800A03F6
Source: Microsoft JScript compilation error
Upvotes: 23
Views: 30502
Reputation: 1
(2023 - Latest): I got a similar Error. Go to the file by copying that path right click -> open with -> (by default its set to window script host) click(change)->select node (if u cant find node option)=> Install Node and open it by search an app in pc reference img and open with the node
u can see the icons will change js file to node now it will work fine!!
Upvotes: 0
Reputation: 43
Associating .JS files to node.exe is the way to solve this.
BUT after struggling with the same issue, I wanted to add that the file association needs to be done with the same USER that you are working with the Terminal/Shell.
So if you use the Terminal as a Admin, you must login with your Admin Account just to fix the file association.
Cheers
Upvotes: 0
Reputation: 11
make sure you have all these mentioned as part of path C:\Users\AppData\Roaming\npm\node_modules@angular\cli C:\Users\AppData\Roaming\npm C:\Program Files\nodejs
in my case, before npm install -g @angular/cli, the path of my system variable was:
C:\Users\AppData\Roaming\npm\node_modules@angular\cli\bin
I remove \bin and work!!!!!
Upvotes: 1
Reputation: 1
make sure you have proper path variable configured as shown below
Go to your system variable settings
make sure you have all these mentioned as part of path C:\Users<userfolder>\AppData\Roaming\npm\node_modules@angular\cli C:\Users<userfolder>\AppData\Roaming\npm C:\Program Files\nodejs
Upvotes: 0
Reputation: 1
I ran into this exact issue after updating to Angular CLI 13. Tried tons of different suggestions from other threads. What is described in the solutions here is essentially what worked for me, but I just want to point out a possible alternative method to applying the fix that doesn't associate all JS files with node.js.
Trying to execute a script from package.json on Windows throws a JScript error
In your windows system environment variables is one variable called PATHEXT. If the value contains .JS;
, remove it. Then restart your CMD windows.
Upvotes: 0
Reputation: 7404
This is how I solved it: (on windows 10)
Go to C:\Users\<your_username>\AppData\Roaming\npm\node_modules\@angular\cli\bin
Check for ng.js
Right click on ng.js file and click on "properties
" option
You need to open it with node.exe so click on "Change" button go to node js installed directory and
(example: C:\Program Files\nodejs\node.exe)
Select node.exe
Click on OK
It should change the color of ng.js like below:
Now try ng -v and other ng commands
Upvotes: 27
Reputation: 11
Installing this exact Angular version:
npm -g install @angular/[email protected]
instead of the latest version:
npm -g install @angular/cli
fixed the above error.
Upvotes: 1
Reputation: 481
Update:
On Windows .js files are associated to Windows Scripting Host by default, so the script will not be run with Node.
Open a file explorer and find a JavaScript file, open the JavaScript file's properties and then "open with", select the Node.js program file to open that kind of files.
The error should stop after doing this.
Upvotes: 47