NPM运行保存问题解决

2024-02-21 11:42:26 浏览数 (1)

问题描述

我在控制台运行如下命令

代码语言:javascript复制
npm run dev

结果报出如下错误

代码语言:javascript复制
> form-generator@0.2.0 dev
> vue-cli-service serve

 INFO  Starting development server...
10% building 4/4 modules 0 active(node:4920) [DEP0111] DeprecationWarning: Access to process.binding('http_parser') is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)
10% building 4/6 modules 2 active D:develop_studyform-generatornode_moduleswebpackhotdev-server.jsError: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:69:19)
    at Object.createHash (node:crypto:133:10)
    at module.exports (D:develop_studyform-generatornode_moduleswebpacklibutilcreateHash.js:135:53)
    at NormalModule._initBuildHash (D:develop_studyform-generatornode_moduleswebpacklibNormalModule.js:417:16)
    at handleParseError (D:develop_studyform-generatornode_moduleswebpacklibNormalModule.js:471:10)
    at D:develop_studyform-generatornode_moduleswebpacklibNormalModule.js:503:5
    at D:develop_studyform-generatornode_moduleswebpacklibNormalModule.js:358:12
    at D:develop_studyform-generatornode_modulesloader-runnerlibLoaderRunner.js:373:3
    at iterateNormalLoaders (D:develop_studyform-generatornode_modulesloader-runnerlibLoaderRunner.js:214:10)
    at iterateNormalLoaders (D:develop_studyform-generatornode_modulesloader-runnerlibLoaderRunner.js:221:10)
    at D:develop_studyform-generatornode_modulesloader-runnerlibLoaderRunner.js:236:3
    at runSyncOrAsync (D:develop_studyform-generatornode_modulesloader-runnerlibLoaderRunner.js:130:11)
    at iterateNormalLoaders (D:develop_studyform-generatornode_modulesloader-runnerlibLoaderRunner.js:232:2)
    at Array.<anonymous> (D:develop_studyform-generatornode_modulesloader-runnerlibLoaderRunner.js:205:4)
    at Storage.finished (D:develop_studyform-generatornode_modulesenhanced-resolvelibCachedInputFileSystem.js:55:16)
    at D:develop_studyform-generatornode_modulesenhanced-resolvelibCachedInputFileSystem.js:91:9
Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:69:19)
    at Object.createHash (node:crypto:133:10)
    at module.exports (D:develop_studyform-generatornode_moduleswebpacklibutilcreateHash.js:135:53)
    at NormalModule._initBuildHash (D:develop_studyform-generatornode_moduleswebpacklibNormalModule.js:417:16)
    at handleParseError (D:develop_studyform-generatornode_moduleswebpacklibNormalModule.js:471:10)
    at D:develop_studyform-generatornode_moduleswebpacklibNormalModule.js:503:5
    at D:develop_studyform-generatornode_moduleswebpacklibNormalModule.js:358:12
    at D:develop_studyform-generatornode_modulesloader-runnerlibLoaderRunner.js:373:3
    at iterateNormalLoaders (D:develop_studyform-generatornode_modulesloader-runnerlibLoaderRunner.js:214:10)
    at iterateNormalLoaders (D:develop_studyform-generatornode_modulesloader-runnerlibLoaderRunner.js:221:10)
    at D:develop_studyform-generatornode_modulesloader-runnerlibLoaderRunner.js:236:3
    at runSyncOrAsync (D:develop_studyform-generatornode_modulesloader-runnerlibLoaderRunner.js:130:11)
    at iterateNormalLoaders (D:develop_studyform-generatornode_modulesloader-runnerlibLoaderRunner.js:232:2)
    at Array.<anonymous> (D:develop_studyform-generatornode_modulesloader-runnerlibLoaderRunner.js:205:4)
    at Storage.finished (D:develop_studyform-generatornode_modulesenhanced-resolvelibCachedInputFileSystem.js:55:16)
    at D:develop_studyform-generatornode_modulesenhanced-resolvelibCachedInputFileSystem.js:91:9
node:internal/crypto/hash:69
  this[kHandle] = new _Hash(algorithm, xofLen);
                  ^

Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:69:19)
    at Object.createHash (node:crypto:133:10)
    at module.exports (D:develop_studyform-generatornode_moduleswebpacklibutilcreateHash.js:135:53)
    at NormalModule._initBuildHash (D:develop_studyform-generatornode_moduleswebpacklibNormalModule.js:417:16)
    at handleParseError (D:develop_studyform-generatornode_moduleswebpacklibNormalModule.js:471:10)
    at D:develop_studyform-generatornode_moduleswebpacklibNormalModule.js:503:5
    at D:develop_studyform-generatornode_moduleswebpacklibNormalModule.js:358:12
    at D:develop_studyform-generatornode_modulesloader-runnerlibLoaderRunner.js:373:3
    at iterateNormalLoaders (D:develop_studyform-generatornode_modulesloader-runnerlibLoaderRunner.js:214:10)
    at Array.<anonymous> (D:develop_studyform-generatornode_modulesloader-runnerlibLoaderRunner.js:205:4)
    at Storage.finished (D:develop_studyform-generatornode_modulesenhanced-resolvelibCachedInputFileSystem.js:55:16)
    at D:develop_studyform-generatornode_modulesenhanced-resolvelibCachedInputFileSystem.js:91:9
    at D:develop_studyform-generatornode_modulesgraceful-fsgraceful-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.19.0

百度了一下,是说版本不对,不是LTS版本,建议我更换Node版本 我本机安装了nvm管理工具,所以通过nvm去查询下node的版本信息

代码语言:javascript复制
nvm list available
##或者也可以用如下的别名ls来执行
nvm ls available

然后看到如下可以安装的版本信息

代码语言:javascript复制
|   CURRENT    |     LTS      |  OLD STABLE  | OLD UNSTABLE |
|--------------|--------------|--------------|--------------|
|    21.6.2    |   20.11.1    |   0.12.18    |   0.11.16    |
|    21.6.1    |   20.11.0    |   0.12.17    |   0.11.15    |
|    21.6.0    |   20.10.0    |   0.12.16    |   0.11.14    |
|    21.5.0    |    20.9.0    |   0.12.15    |   0.11.13    |
|    21.4.0    |   18.19.1    |   0.12.14    |   0.11.12    |
|    21.3.0    |   18.19.0    |   0.12.13    |   0.11.11    |
|    21.2.0    |   18.18.2    |   0.12.12    |   0.11.10    |
|    21.1.0    |   18.18.1    |   0.12.11    |    0.11.9    |
|    21.0.0    |   18.18.0    |   0.12.10    |    0.11.8    |
|    20.8.1    |   18.17.1    |    0.12.9    |    0.11.7    |
|    20.8.0    |   18.17.0    |    0.12.8    |    0.11.6    |
|    20.7.0    |   18.16.1    |    0.12.7    |    0.11.5    |
|    20.6.1    |   18.16.0    |    0.12.6    |    0.11.4    |
|    20.6.0    |   18.15.0    |    0.12.5    |    0.11.3    |
|    20.5.1    |   18.14.2    |    0.12.4    |    0.11.2    |
|    20.5.0    |   18.14.1    |    0.12.3    |    0.11.1    |
|    20.4.0    |   18.14.0    |    0.12.2    |    0.11.0    |
|    20.3.1    |   18.13.0    |    0.12.1    |    0.9.12    |
|    20.3.0    |   18.12.1    |    0.12.0    |    0.9.11    |
|    20.2.0    |   18.12.0    |   0.10.48    |    0.9.10    |

可以看到LTS下的版本列表,我选择了18.19.1版本,执行如下命令进行安装

代码语言:javascript复制
nvm install 18.19.1

然后就静静等待安装结束,直到看到控制台输出如下信息,表示安装已经完成

代码语言:javascript复制
Downloading node.js version 18.19.1 (64-bit)...
Complete
Downloading npm version 10.2.4... Complete
Installing npm v10.2.4...

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

nvm use 18.19.1

安装完成后我们用如下命令查看一下

代码语言:javascript复制
nvm ls

执行结果如下

代码语言:javascript复制
18.19.1

然后我们执行nvm use 18.19.1就可以生效该版本

代码语言:javascript复制
nvm use 18.19.1

接下来就可以愉快的编码了

0 人点赞