Vue CLI 错误创建新项目(npm 错误)

Vue CLI error creating new project (npm error)

请帮我解决这个问题。我无法创建新的 Vue CLI 项目。以前效果不错!现在不工作...

Vue CLI v4.2.3

✨ Creating project in /Web develop/Vue Projects/new.

Initializing git repository...

⚙️ Installing CLI plugins. This might take a while...

npm ERR! Unexpected end of JSON input while parsing near '...loader":"~0.8.0","js-'

npm ERR! A complete log of this run can be found in:

npm ERR! /Users/Malaka/.npm/_logs/2020-03-25T06_30_10_474Z-debug.log ERROR command failed: npm install --loglevel error

似乎是缓存错误

运行

npm cache clean --force

然后尝试重新创建项目

这很奇怪。我只是尝试重新安装 Vue cli 包。

有一个已弃用的 vue-cli 包,可能是您安装了那个包而不是官方包 @vue/cli

无论哪种方式,只需使用

卸载它
npm uninstall [your-vue-cli-package] -g

然后重新安装。

npm install @vue/cli -g

让我们试试这个

$ sudo npm uninstall -g vue

$ sudo npm uninstall -g vue-cli

$ sudo npm uninstall -g @vue/cli

$ sudo npm cache clean --force

$ sudo npm install -g vue

$ sudo npm install -g @vue/cli

问题记录:

npm ERR! code ERR_SOCKET_TIMEOUT
npm ERR! network Socket timeout
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly.  See: 'npm help config'

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\DraKoan\AppData\Local\npm-cache\_logs22-04-19T17_09_34_388Z-debug-0.log
 ERROR  Error: command failed: npm install --loglevel error --legacy-peer-deps
Error: command failed: npm install --loglevel error --legacy-peer-deps
    at ChildProcess.<anonymous> (C:\Users\DraKoan\AppData\Roaming\npm\node_modules\@vue\cli\lib\util\executeCommand.js:138:16)
    at ChildProcess.emit (node:events:526:28)
    at ChildProcess.cp.emit (C:\Users\DraKoan\AppData\Roaming\npm\node_modules\@vue\cli\node_modules\cross-spawn\lib\enoent.js:34:29)
    at maybeClose (node:internal/child_process:1092:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)

求解:

在配置中检查代理

npm config edit
npm config --global edit

清理并设置代理

npm config set proxy null
npm config set proxy false