Loading

npm run serve 报错


解决:npm run serve 错误,或者 npm run build 错误

错误原因:

使用了 过高版本的 Node.js

解决办法:

本人电脑上安装了,nvm 可以快速的 安装node 的其他版本,当 降版本到 Node v16.14.1 时,才可以正常运行(太坑了)

nvm 安装 v16.14.1  (或者 度娘一下,手动安装其他版本的即可)

nvm list available

nvm install 16.14.1

nvm use 16.14.1

node -v

C:\Users\aa\Desktop\login01\aa\ee>nvm list available

|   CURRENT    |     LTS      |  OLD STABLE  | OLD UNSTABLE |
|--------------|--------------|--------------|--------------|
|    20.2.0    |   18.16.0    |   0.12.18    |   0.11.16    |
|    20.1.0    |   18.15.0    |   0.12.17    |   0.11.15    |
|    20.0.0    |   18.14.2    |   0.12.16    |   0.11.14    |
|    19.9.0    |   18.14.1    |   0.12.15    |   0.11.13    |
|    19.8.1    |   18.14.0    |   0.12.14    |   0.11.12    |
|    19.8.0    |   18.13.0    |   0.12.13    |   0.11.11    |
|    19.7.0    |   18.12.1    |   0.12.12    |   0.11.10    |
|    19.6.1    |   18.12.0    |   0.12.11    |    0.11.9    |
|    19.6.0    |   16.20.0    |   0.12.10    |    0.11.8    |
|    19.5.0    |   16.19.1    |    0.12.9    |    0.11.7    |
|    19.4.0    |   16.19.0    |    0.12.8    |    0.11.6    |
|    19.3.0    |   16.18.1    |    0.12.7    |    0.11.5    |
|    19.2.0    |   16.18.0    |    0.12.6    |    0.11.4    |
|    19.1.0    |   16.17.1    |    0.12.5    |    0.11.3    |
|    19.0.1    |   16.17.0    |    0.12.4    |    0.11.2    |
|    19.0.0    |   16.16.0    |    0.12.3    |    0.11.1    |
|   18.11.0    |   16.15.1    |    0.12.2    |    0.11.0    |
|   18.10.0    |   16.15.0    |    0.12.1    |    0.9.12    |
|    18.9.1    |   16.14.2    |    0.12.0    |    0.9.11    |
|    18.9.0    |   16.14.1    |   0.10.48    |    0.9.10    |

This is a partial list. For a complete list, visit https://nodejs.org/en/download/releases

C:\Users\aa\Desktop\login01\aa\ee>nvm install 16.14.1
Downloading node.js version 16.14.1 (64-bit)...
Extracting node and npm...
Complete
npm v8.5.0 installed successfully.


Installation complete. If you want to use this version, type

nvm use 16.14.1

C:\Users\aa\Desktop\login01\aa\ee>nvm use 16.14.1
Now using node v16.14.1 (64-bit)

C:\Users\aa\Desktop\login01\aa\ee>npm -v
8.5.0

C:\Users\aa\Desktop\login01\aa\ee>node -v
v16.14.1

错误日志:

PS C:\Users\aa\Desktop\login01\aa\ee> npm run serve

> ee@0.1.0 serve
> vue-cli-service serve

 INFO  Starting development server...
 WARN  A new version of sass-loader is available. Please upgrade for best experience.
10% building 0/1 modules 1 active ...//10.245.74.2:8080&sockPath=/sockjs-node C:\Users\aa\Desktop\login01\aa\ee\node_modules\webpack\hot\dev-server.js ./src/main.10% building 2/4 modules 2 active C:\Users\aa\Desktop\login01\aa\ee\node_modules\webpack\hot\dev-server.jsError: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:71:19)
    at Object.createHash (node:crypto:133:10)
    at module.exports (C:\Users\aa\Desktop\login01\aa\ee\node_modules\webpack\lib\util\createHash.js:135:53)
    at NormalModule._initBuildHash (C:\Users\aa\Desktop\login01\aa\ee\node_modules\webpack\lib\NormalModule.js:417:16)
    at handleParseError (C:\Users\aa\Desktop\logi01\aa\ee\node_modules\webpack\lib\NormalModule.js:471:10)
    at C:\Users\aa\Desktop\login01\aa\ee\node_modules\webpack\lib\NormalModule.js:503:5
    at C:\Users\aa\Desktop\login01\aa\ee\node_modules\webpack\lib\NormalModule.js:358:12
    at C:\Users\aa\Desktop\login01\aa\ee\node_modules\loader-runner\lib\LoaderRunner.js:373:3
    at iterateNormalLoaders (C:\Users\aa\Desktop\login01\aa\ee\node_modules\loader-runner\lib\LoaderRunner.js:214:10)
    at iterateNormalLoaders (C:\Users\aa\Desktop\login01\aa\ee\node_modules\loader-runner\lib\LoaderRunner.js:221:10)
    at C:\Users\aa\Desktop\login01\aa\ee\node_modules\loader-runner\lib\LoaderRunner.js:236:3
    at runSyncOrAsync (C:\Users\aa\Desktop\login01\aa\ee\node_modules\loader-runner\lib\LoaderRunner.js:130:11)
    at iterateNormalLoaders (C:\Users\aaDesktop\login01\aa\ee\node_modules\loader-runner\lib\LoaderRunner.js:232:2)
    at Array.<anonymous> (C:\Users\aa\Desktop\login01\aa\ee\node_modules\loader-runner\lib\LoaderRunner.js:205:4)
    at Storage.finished (C:\Users\aa\Desktop\login01\aa\ee\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:55:16)
    at C:\Users\aa\Desktop\login01\aa\ee\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:91:9
10% building 2/5 modules 3 active ...C:\Users\aa\Desktop\login01\aa\ee\node_modules\eslint-loader\index.js??ref--14-0!C:\Users\aa\Desktop\login01\aa\ee\src\main.jsnode:internal/crypto/hash:71
  this[kHandle] = new _Hash(algorithm, xofLen);
                  ^

    at new Hash (node:internal/crypto/hash:71:19)
    at module.exports (C:\Users\aa\Desktop\login01\aa\ee\node_modules\webpack\lib\util\createHash.js:135:53)
    at handleParseError (C:\Useraa\Desktop\login01\aa\ee\node_modules\webpack\lib\NormalModule.js:471:10)
    at C:\Users\aa\Desktop\login01\aa\ee\node_modules\webpack\lib\NormalModule.js:503:5
    at C:\Users\aa\Desktop\login01\aa\ee\node_modules\webpack\lib\NormalModule.js:358:12
    at C:\Users\aa广\Desktop\login01\aa\ee\node_modules\loader-runner\lib\LoaderRunner.js:373:3
    at iterateNormalLoaders (C:\Users\aa\Desktop\login01\aa\ee\node_modules\loader-runner\lib\LoaderRunner.js:214:10)
    at Array.<anonymous> (C:\Users\top\login01\aa\ee\node_modules\graceful-fs\graceful-fs.js:123:16
    at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read_file_context:68:3) {
  opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
  library: 'digital envelope routines',
  reason: 'unsupported',
  code: 'ERR_OSSL_EVP_UNSUPPORTED'
}

Node.js v18.16.0

运行一个新的vue项目时,报错异常。

尝试过以下几种方式

  1. npm install @vue/cli@3 -g 无效

  2. npm install @vue/cli@4 -g 无效

甚至 使用 vue create new_vue 创建一个新的项目后,都无法正常运行。

posted @ 2023-06-08 21:53  小小的编程员  阅读(302)  评论(0编辑  收藏  举报