Vue CLI项目遇Windows Script Host报错:Microsoft JScript编译错误(第1469行)
Hey there, I’ve run into this exact error a few times when working with Vue CLI on Windows, so let’s break down how to fix it. That Microsoft JScript compilation error is almost always tied to misconfigured script handlers or environment conflicts between Node.js and Windows. Here’s what you can try:
Verify Node.js and Vue CLI versions
First, make sure you’re running a stable LTS version of Node.js—preview or outdated builds often clash with Windows’ script environment. Open your terminal and run these commands to check:node -v vue --versionIf your Node.js version is outdated, grab the latest LTS build, then reinstall Vue CLI globally to ensure compatibility:
npm uninstall -g @vue/cli npm install -g @vue/cliFix Windows
.jsfile association
The most common culprit here is Windows trying to run.jsfiles with its own JScript engine instead of Node.js. To correct this:- Open Command Prompt as Administrator.
- Run this command (replace the Node.js path with your actual installation location if it differs):
ftype NodeJSFile="C:\Program Files\nodejs\node.exe" "%1" %* - Set the file association to use Node.js for
.jsfiles:assoc .js=NodeJSFile
Restart your terminal after this, then try running
npm run serveagain.Clean npm cache and reinstall dependencies
Corrupted cache or node modules can trigger weird script errors too. Do the following in your project directory:- Delete the
node_modulesfolder andpackage-lock.jsonfile. - Clear the npm cache:
npm cache clean --force - Reinstall fresh dependencies:
npm install
- Delete the
Switch to PowerShell
Sometimes Command Prompt has environment variable quirks that cause this issue. Try using PowerShell (run as Administrator) to create your Vue project or start the dev server—this often bypasses the script handler conflict entirely.Check project script configuration
Double-check your project’spackage.jsonfile to ensure the scripts are correctly set up. The defaultserveandbuildcommands should look like this:"scripts": { "serve": "vue-cli-service serve", "build": "vue-cli-service build" }If anything looks off, regenerate the project with Vue CLI to get fresh, default scripts.
内容的提问来源于stack exchange,提问作者KNIGHT MAHAJAN

