win10电脑npm run dev报错解决

npm run dev报错解决

    • 出现错误前的操作步骤
    • 错误日志
    • 解决步骤

出现错误前的操作步骤

  1. 初始化Vue项目
$ npm create [email protected]
  1. 创建项目文件夹client
Vue.js - The Progressive JavaScript Framework

✔ Project name: › client
✔ Add TypeScript? › No
✔ Add JSX Support? › No
✔ Add Vue Router for Single Page Application development? › Yes
✔ Add Pinia for state management? › No
✔ Add Vitest for Unit Testing? › No
✔ Add ESLint for code quality? › No
  1. 安装依赖,运行开发服务
$ cd client
$ npm install
$ npm run dev

错误日志

日志路径:C:\Users\\AppData\Roaming\npm-cache_logs
日志详细:

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'run',
1 verbose cli   'dev'
1 verbose cli ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'predev', 'dev', 'postdev' ]
5 info lifecycle [email protected]~predev: [email protected]
6 info lifecycle [email protected]~dev: [email protected]
7 verbose lifecycle [email protected]~dev: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]~dev: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;D:\kode\pingtaikaifa\flask-vue-crud\client\node_modules\.bin;C:\Program Files\PowerShell\7;C:\Program Files\Common Files\Oracle\Java\javapath;C:\Program Files\OpenSSL-Win64\bin;C:\Python39\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;D:\mysql\bin;C:\Program Files\nodejs\;C:\ProgramData\chocolatey\bin;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Users\<user>\AppData\Roaming\Python\Python39\Scripts;C:\Program Files\Go\bin;C:\sqlite;C:\Program Files\dotnet\;C:\apache-jmeter-5.5\bin;C:\Program Files\Java\jdk-17.0.5\bin;JMETER_HOME%\bin;D:\programs\allure-2.9.0\bin;C:\Program Files\PowerShell\7\;D:\programs\Git\cmd;C:\Users\<user>\AppData\Local\Programs\Python\Python311\Scripts\;C:\Users\<user>\AppData\Local\Programs\Python\Python311\;C:\Users\<user>\scoop\apps\openjdk17\current\bin;C:\Users\<user>\scoop\apps\android-sdk\current\tools\bin;C:\Users\<user>\scoop\apps\ruby\current\bin;C:\Users\<user>\scoop\apps\ruby\current\gems\bin;C:\Users\<user>\scoop\shims;C:\Users\<user>\AppData\Local\Microsoft\WindowsApps;C:\Users\<user>\AppData\Roaming\npm;C:\Users\<user>\AppData\Local\Programs\Fiddler;C:\Users\<user>\go\bin;D:\programs\Microsoft VS Code\bin
9 verbose lifecycle [email protected]~dev: CWD: D:\kode\pingtaikaifa\flask-vue-crud\client
10 silly lifecycle [email protected]~dev: Args: [ '/d /s /c', 'vite' ]
11 silly lifecycle [email protected]~dev: Returned: code: 1  signal: null
12 info lifecycle [email protected]~dev: Failed to exec dev script
13 verbose stack Error: [email protected] dev: `vite`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:375:28)
13 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:375:28)
13 verbose stack     at maybeClose (internal/child_process.js:1055:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
14 verbose pkgid [email protected]
15 verbose cwd D:\kode\pingtaikaifa\flask-vue-crud\client
16 verbose Windows_NT 10.0.19045
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "dev"
18 verbose node v14.17.1
19 verbose npm  v6.14.13
20 error code ELIFECYCLE
21 error errno 1
22 error [email protected] dev: `vite`
22 error Exit status 1
23 error Failed at the [email protected] dev script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

解决步骤

  1. 官网下载最新LTS安装包:https://nodejs.org/dist/v18.17.1/node-v18.17.1-x64.msi
  2. 运行安装向导,覆盖旧版本目录(cmd查看:where node
  3. 验证安装成功:node -v

你可能感兴趣的:(npm,前端,node.js)