不兼容版本及报错
系统环境:
node.js: v17.6.0
npm: 8.5.1
运行npm run dev 报错
//报错
INFO Starting development server...
10% building 2/5 modules 3 active /Users/admin/Desktop/universe/universe_admin_base/node_modules/webpack/hot/dev-server.jsError: error:0308010C:digital envelope routines::unsupported
at new Hash (node:internal/crypto/hash:67:19)
at Object.createHash (node:crypto:135:10)
at module.exports (/Users/admin/Desktop/universe/universe_admin_base/node_modules/webpack/lib/util/createHash.js:135:53)
at NormalModule._initBuildHash (/Users/admin/Desktop/universe/universe_admin_base/node_modules/webpack/lib/NormalModule.js:417:16)
at handleParseError (/Users/admin/Desktop/universe/universe_admin_base/node_modules/webpack/lib/NormalModule.js:471:10)
at /Users/admin/Desktop/universe/universe_admin_base/node_modules/webpack/lib/NormalModule.js:503:5
at /Users/admin/Desktop/universe/universe_admin_base/node_modules/webpack/lib/NormalModule.js:358:12
at /Users/admin/Desktop/universe/universe_admin_base/node_modules/loader-runner/lib/LoaderRunner.js:373:3
at iterateNormalLoaders (/Users/admin/Desktop/universe/universe_admin_base/node_modules/loader-runner/lib/LoaderRunner.js:214:10)
at iterateNormalLoaders (/Users/admin/Desktop/universe/universe_admin_base/node_modules/loader-runner/lib/LoaderRunner.js:221:10)
at /Users/admin/Desktop/universe/universe_admin_base/node_modules/loader-runner/lib/LoaderRunner.js:236:3
at runSyncOrAsync (/Users/admin/Desktop/universe/universe_admin_base/node_modules/loader-runner/lib/LoaderRunner.js:130:11)
at iterateNormalLoaders (/Users/admin/Desktop/universe/universe_admin_base/node_modules/loader-runner/lib/LoaderRunner.js:232:2)
at Array.<anonymous> (/Users/admin/Desktop/universe/universe_admin_base/node_modules/loader-runner/lib/LoaderRunner.js:205:4)
at Storage.finished (/Users/admin/Desktop/universe/universe_admin_base/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:55:16)
at /Users/admin/Desktop/universe/universe_admin_base/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:91:9
node:internal/crypto/hash:67
this[kHandle] = new _Hash(algorithm, xofLen);
^
Error: error:0308010C:digital envelope routines::unsupported
at new Hash (node:internal/crypto/hash:67:19)
at Object.createHash (node:crypto:135:10)
at module.exports (/Users/admin/Desktop/universe/universe_admin_base/node_modules/webpack/lib/util/createHash.js:135:53)
at NormalModule._initBuildHash (/Users/admin/Desktop/universe/universe_admin_base/node_modules/webpack/lib/NormalModule.js:417:16)
at handleParseError (/Users/admin/Desktop/universe/universe_admin_base/node_modules/webpack/lib/NormalModule.js:471:10)
at /Users/admin/Desktop/universe/universe_admin_base/node_modules/webpack/lib/NormalModule.js:503:5
at /Users/admin/Desktop/universe/universe_admin_base/node_modules/webpack/lib/NormalModule.js:358:12
at /Users/admin/Desktop/universe/universe_admin_base/node_modules/loader-runner/lib/LoaderRunner.js:373:3
at iterateNormalLoaders (/Users/admin/Desktop/universe/universe_admin_base/node_modules/loader-runner/lib/LoaderRunner.js:214:10)
at Array.<anonymous> (/Users/admin/Desktop/universe/universe_admin_base/node_modules/loader-runner/lib/LoaderRunner.js:205:4)
at Storage.finished (/Users/admin/Desktop/universe/universe_admin_base/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:55:16)
at /Users/admin/Desktop/universe/universe_admin_base/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:91:9
at /Users/admin/Desktop/universe/universe_admin_base/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 v17.6.0
使用node版本降级解决了该问题(Mac):
(1)安装node版本管理模块n
sudo npm install n -g
(2)版本降级/升级
sudo n 版本号
例如:sudo n 16.14.2
最后成功了:
INFO Starting development server...
98% after emitting CopyPlugin
DONE Compiled successfully in 8090ms 23:13:49
App running at:
- Local: http://localhost:9528/
- Network: http://192.168.1.102:9528/
Note that the development build is not optimized.
To create a production build, run npm run build.