Node.js Webpack ERR_OSSL_EVP_UNSUPPORTED

huangapple go评论68阅读模式
英文:

Node.js Webpack ERR_OSSL_EVP_UNSUPPORTED

问题

  1. 为什么突然出现了SSL更改?
    我在公司办公用的是个人电脑,Node.js版本为18.14.0(没有升级)。
    我的电脑配置默默地改变了吗?我的公司升级了我的浏览器?还是其他原因?

  2. 除了每次在命令提示符中输入,我想要在package.json中使用,并尝试添加NODE_OPTIONS=--openssl-legacy-provider,如下所示:

"scripts": {
        "test": "echo \"Error: no test specified\" && exit 1",
        "build": "set NODE_ENV=production&& webpack --mode production",
        "watch": "set NODE_OPTIONS=--openssl-legacy-provider NODE_ENV=development&& webpack --mode development --watch"
    },

然后,我可以使用"npm run watch"运行应用程序,而不会出现SSL错误,但process.env.NODE_ENV变为未定义。
那么在package.json中的正确语法是什么?

我的环境:
Windows 10 专业版 64位
Chrome 107.0.5304.121 64位
Node.js v18.14.0
Webpack 5.38.1

英文:

Orginallly I can launch my app at localhost using "npm run watch" normally. But few days after I got SSL related errors:<br/>- error:03000086:digital envelope routines::initialization error and
<br/>- ERR_OSSL_EVP_UNSUPPORTED.
<br/>Finally I figured out I have to type this in command prompt than run successfully:<br/> set NODE_OPTIONS=--openssl-legacy-provider &amp;&amp; npm run watch


  1. Why suddenly there are SSL changes?
    I am using company office PC and Node.js v18.14.0 (No upgrade).
    My pc config changed silently? My company upgraded my browser? or anything else?

  1. Other than to type every time in command prompt, I want to use package.json and tried to add NODE_OPTIONS=--openssl-legacy-provider like:
&quot;scripts&quot;: {
        &quot;test&quot;: &quot;echo \&quot;Error: no test specified\&quot; &amp;&amp; exit 1&quot;,
        &quot;build&quot;: &quot;set NODE_ENV=production&amp;&amp; webpack --mode production&quot;,
        &quot;watch&quot;: &quot;set NODE_OPTIONS=--openssl-legacy-provider NODE_ENV=development&amp;&amp; webpack --mode development --watch&quot;
    },

Then I can run the app using "npm run watch" without SSL error but process.env.NODE_ENV became undefined.
So what is the correct syntax in package.json?


My environment:<br/>
Windows 10 professional 64bit<br/>
Chrome 107.0.5304.121 64bit<br/>
Node.js v18.14.0<br/>
Webpack 5.38.1<br/>

答案1

得分: 1

Q1: 在Windows上,Node.js已经编译了OpenSSL(即不会动态链接),所以除非更新Node.js,否则这不应该发生变化。Node.js 18使用了OpenSSL 3.0,其中包含了新的限制,因此自从安装Node.js 18以来,您应该已经有了这些限制,尽管根据您的应用程序实际执行了哪些需要旧的加密算法的操作,可能直到"几天"后才会触发。我不认为webpack会在每次调用时更改它所使用的加密算法,但我对此不是专家,而且我们对您的应用程序是否执行其他任何操作一无所知。您的网络浏览器与此无关。

Q2: 尽管Unix shell(至少大多数情况下)可以在一条命令中分配多个环境变量,但Windows CMD不支持。您可以使用多个命令来实现:

"set NODE_OPTIONS=--openssl-legacy-provider && set NODE_ENV=blahblah && ..."
英文:

Q1: Node on Windows has OpenSSL compiled-in (i.e. does not link dynamically) so this should not have changed without updating node. Node18 does use OpenSSL3.0 which has the new restrictions, so you should have had them since Node18 was installed -- although depending on what your app does it might not have actually done whatever operation(s) require the legacy crypto algorithms until "a few days". I don't think webpack changes the crypto it uses from one invocation to another, but I'm far from an expert on that, and we don't have any clue what else if anything your app does. Your web browser is irrelevant.

Q2: Although Unix shells (at least most of them) can assign multiple envvars (or shellvars) in one command, Windows CMD cannot. Use multiple commands:

&quot;set NODE_OPTIONS=--openssl-legacy-provider&amp;&amp; set NODE_ENV=blahblah&amp;&amp; ...&quot;

huangapple
  • 本文由 发表于 2023年5月30日 12:29:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/76361634.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定