You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Windows7系统恢复后Vue CLI项目npm run dev无法运行求助

Troubleshooting npm run dev Failure in Vue.js Projects

Hey there, let's work through this issue you're having where npm run dev won't execute properly for any Vue.js project—even after trying common fixes like reinstalling Node.js, updating npm, recreating projects, and deleting npm's AppData folder. I've gone through your error log, and here are some targeted steps to resolve this:

Key Observations from Your Log

  • You're using Node.js v8.9.4 and npm v5.6.0—both are quite outdated, which is likely a major source of compatibility issues with modern Vue.js tooling.
  • The failing dev script is: webpack-dev-server --inline --progress --config build/webpack.dev.conf.js, with an exit code 1 (the npm log doesn't show the root error, so we need deeper checks).

1. Upgrade Node.js and npm to a Supported LTS Version

Old Node.js versions lack security updates and often clash with newer webpack, Vue CLI, and dependency versions. Here's how to fix this properly:

  • Uninstall your current Node.js installation completely.
  • Install Node Version Manager (nvm) for Windows to easily manage multiple Node versions.
  • Use nvm to install a supported LTS version (e.g., Node.js 18.x, which works with both Vue 2 and Vue 3):
    nvm install lts/hydrogen
    nvm use lts/hydrogen
    
  • Verify the versions afterward:
    node -v  # Should show 18.x.x
    npm -v   # Should show 9.x.x or higher
    

2. Purge Project Dependencies and Reinstall

Corrupted or mismatched dependencies in node_modules can persist even in new projects. Try this for your test project:

  • Delete the node_modules folder in your project directory.
  • Delete the package-lock.json file.
  • Clear npm's global cache:
    npm cache clean --force
    
  • Reinstall dependencies:
    npm install
    
  • Try running npm run dev again.

3. Fix Webpack-Dev-Server Compatibility

Since your project uses webpack-dev-server directly (common in older Vue CLI 2 projects), the version might not be compatible with your old Node.js version. Install a compatible version explicitly:

npm install webpack-dev-server@3.11.2 --save-dev

This version is known to work with Node.js 8.x. After installation, re-run npm run dev.

4. Get Detailed Error Output

The npm log only shows the exit code, not the actual error from webpack-dev-server. Run the dev script directly in your terminal to see what's going wrong:

webpack-dev-server --inline --progress --config build/webpack.dev.conf.js

This should print specific errors (like missing modules, port conflicts, or permission issues) that can point you to the root cause.

5. Check for Permission or PATH Conflicts

  • Run Terminal as Administrator: Windows permissions can block script execution. Right-click your command prompt/PowerShell and select "Run as administrator", then navigate to your project folder and run npm run dev.
  • Inspect PATH Conflicts: Your system PATH includes many tools (like Borland CBuilder). Ensure there's no conflicting command named webpack-dev-server from another tool. You can check where the command is located with:
    where webpack-dev-server
    
    It should point to your project's node_modules/.bin folder.

Your Original Error Log

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Users\\Mat\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'run',
1 verbose cli 'dev' ]
2 info using npm@5.6.0
3 info using node@v8.9.4
4 verbose run-script [ 'predev', 'dev', 'postdev' ]
5 info lifecycle testvue@1.0.0~predev: testvue@1.0.0
6 info lifecycle testvue@1.0.0~dev: testvue@1.0.0
7 verbose lifecycle testvue@1.0.0~dev: unsafe-perm in lifecycle true
8 verbose lifecycle testvue@1.0.0~dev: PATH: C:\\Users\\Mat\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\npm-lifecycle\\node-gyp-bin;C:\\www\\testvue\\node_modules\\.bin;C:\\PROGRA~2\\Borland\\CBUILD~1\\Bin;C:\\PROGRA~2\\Borland\\CBUILD~1\\Projects\\Bpl;C:\\ProgramData\\Oracle\\Java\\javapath;C:\\Program Files (x86)\\AMD APP\\bin\\x86_64;C:\\Program Files (x86)\\AMD APP\\bin\\x86;C:\\Program Files (x86)\\HP SimplePass 2011\\;C:\\Program Files\\Common Files\\Microsoft Shared\\Windows Live;C:\\Program Files (x86)\\Common Files\\Microsoft Shared\\Windows Live;C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program Files (x86)\\Windows Live\\Shared;C:\\Program Files (x86)\\ATI Technologies\\ATI.ACE\\Core-Static;C:\\Program Files\\Intel\\WiFi\\bin\\;C:\\Program Files\\Common Files\\Intel\\WirelessCommon\\;C:\\Program Files (x86)\\Skype\\Phone\\;C:\\xampp\\php;C:\\ProgramData\\ComposerSetup\\bin;C:\\Program Files\\Git\\cmd;C:\\Program Files\\Git\\mingw64\\bin;C:\\Program Files\\Git\\usr\\bin;C:\\Program Files\\nodejs\\;C:\\Program Files\\Microsoft VS Code\\bin;C:\\Users\\Mat\\AppData\\Roaming\\Composer\\vendor\\bin;C:\\Users\\Mat\\AppData\\Local\\atom\\bin;C:\\Users\\Mat\\AppData\\Roaming\\npm
9 verbose lifecycle testvue@1.0.0~dev: CWD: C:\\www\\testvue
10 silly lifecycle testvue@1.0.0~dev: Args: [ '/d /s /c',
10 silly lifecycle 'webpack-dev-server --inline --progress --config build/webpack.dev.conf.js' ]
11 silly lifecycle testvue@1.0.0~dev: Returned: code: 1 signal: null
12 info lifecycle testvue@1.0.0~dev: Failed to exec dev script
13 verbose stack Error: testvue@1.0.0 dev: `webpack-dev-server --inline --progress --config build/webpack.dev.conf.js`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (C:\\Users\\Mat\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\npm-lifecycle\\index.js:285:16)
13 verbose stack at emitTwo (events.js:126:13)
13 verbose stack at EventEmitter.emit (events.js:214:7)
13 verbose stack at ChildProcess.<anonymous> (C:\\Users\\Mat\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\npm-lifecycle\\lib\\spawn.js:55:14)
13 verbose stack at emitTwo (events.js:126:13)
13 verbose stack at ChildProcess.emit (events.js:214:7)
13 verbose stack at maybeClose (internal/child_process.js:925:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
14 verbose pkgid testvue@1.0.0
15 verbose cwd C:\\www\\testvue
16 verbose Windows_NT 6.1.7601
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Mat\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "run" "dev"
18 verbose node v8.9.4
19 verbose npm v5.6.0
20 error code ELIFECYCLE
21 error errno 1
22 error testvue@1.0.0 dev: `webpack-dev-server --inline --progress --config build/webpack.dev.conf.js`
22 error Exit status 1
23 error Failed at the testvue@1.0.0 dev script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

内容的提问来源于stack exchange,提问作者gileneusz

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 03:32:07