vuepress icon indicating copy to clipboard operation
vuepress copied to clipboard

Node 19 Error: error:0308010C:digital envelope routines::unsupported

Open maxfrischknecht opened this issue 1 year ago • 14 comments

  • [x] I confirm that this is an issue rather than a question.

Bug report

npm run dev leads to error Error: error:0308010C:digital envelope routines::unsupported on Node.js v19.6.1

Steps to reproduce

Run npm run dev within Vuepress ^1.5.3 (also tried with 1.9.7) on Node.js v19.6.1

What is expected?

Serving the page

What is actually happening?

After building 40% the script crashes

Other relevant information

Bildschirmfoto 2023-04-04 um 20 53 58
  • Output of npx vuepress info in my VuePress project: Environment Info:

    System: OS: macOS 11.7.3 CPU: (8) x64 Intel(R) Core(TM) i7-4850HQ CPU @ 2.30GHz Binaries: Node: 19.6.1 - /usr/local/bin/node Yarn: 1.22.10 - /usr/local/bin/yarn npm: 9.4.0 - /usr/local/bin/npm Browsers: Chrome: 111.0.5563.146 Edge: Not Found Firefox: 108.0.1 Safari: 16.3 npmPackages: @vuepress/core: undefined (1.9.7) @vuepress/theme-default: 1.9.7 vuepress: ^1.5.3 => 1.9.7 npmGlobalPackages: vuepress: Not Found

maxfrischknecht avatar Apr 05 '23 00:04 maxfrischknecht

I have seen this also with node 18.15.0. I had to go back to the previous version of node LTS 16.20.0 for it to work.

lewissk avatar Apr 07 '23 15:04 lewissk

I have seen this also with node 18.15.0. I had to go back to the previous version of node LTS 16.20.0 for it to work.

I can confirm that this works. Thx

maxfrischknecht avatar Apr 08 '23 15:04 maxfrischknecht

image

The current node version is 18.0.0

kingcwt avatar May 12 '23 07:05 kingcwt

Also see #3095 I wonder if there's a more optimal solution that doesn't require using an older node version.

muang0 avatar Sep 24 '23 20:09 muang0

Is this a problem with Vue, that it can only use Node V16? Is there a way to use current versions of Node so this problem doesn't occur, without doing the insecure "SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve" fix?

sonicviz avatar Oct 02 '23 01:10 sonicviz

For those who came here after a yarn create vuepress-site Would suggest we add this in the template till its fixed though

yarn add cross-env --dev And modify your package.json scripts #package.json: { "scripts": { "dev": "cross-env NODE_OPTIONS=--openssl-legacy-provider vuepress dev src", "build": "cross-env NODE_OPTIONS=--openssl-legacy-provider vuepress build src" }, }

1gn0r4nd avatar Dec 07 '23 13:12 1gn0r4nd

For those who came here after a yarn create vuepress-site Would suggest we add this in the template till its fixed though

yarn add cross-env --dev And modify your package.json scripts #package.json: { "scripts": { "dev": "cross-env NODE_OPTIONS=--openssl-legacy-provider vuepress dev src", "build": "cross-env NODE_OPTIONS=--openssl-legacy-provider vuepress build src" }, }

Thanks for your solution, it helps me a lot, but as to macOS, there is no need to add cross-env, add the node setting is enough for that:

  "docs:build": "NODE_OPTIONS=--openssl-legacy-provider vuepress build docs",

guluguru avatar Jan 16 '24 06:01 guluguru

I'm using nodejs 18.16.0, npm 9.5.1, vuepress 1.9.10 in Windows 11. I can successfully run npm run dev, but get error running npm run build because Client compiling failed with this error (but why?) Setting NODE_OPTIONS works.

Alex6357 avatar Jan 17 '24 15:01 Alex6357

I'm using nodejs 18.16.0, npm 9.5.1, vuepress 1.9.10 in Windows 11. I can successfully run npm run dev, but get error running npm run build because Client compiling failed with this error (but why?) Setting NODE_OPTIONS works.

i had the same problem...I don't know if you still need an answer but for me works change the node version with nvm to node 16.20.0

DoryanPC avatar Mar 12 '24 21:03 DoryanPC

For those who came here after a yarn create vuepress-site Would suggest we add this in the template till its fixed though

yarn add cross-env --dev And modify your package.json scripts #package.json: { "scripts": { "dev": "cross-env NODE_OPTIONS=--openssl-legacy-provider vuepress dev src", "build": "cross-env NODE_OPTIONS=--openssl-legacy-provider vuepress build src" }, }

Thanks @1gn0r4nd ! It worked for me 🙏🏼

leiluspocus avatar Apr 18 '24 10:04 leiluspocus

For any who need to use a newer version of node and don't like the idea of using --openssl-legacy-provider, an alternative solution is to force a specific version of webpack and terser-webpack-plugin. See webpack issue for more details here.

"overrides": {
  "[email protected]": {
    "terser-webpack-plugin": "^4.2.3"
  }
}

In summary the root of this issue is that node 17^ doesn't support the md4 hashing algorithm. So any package which uses crypto.createHash('md4') will throw this error. Vuepress accepts older versions of webpack which use this algorithm by default. Also webpack depends on an outdated version of terser-webpack-plugin which also uses md4.

Hopefully that is merged soon and will help solve this issue. Then we can bump the version of webpack used here and it should be resolved without the need for an override.

MrMarCode avatar May 03 '24 01:05 MrMarCode

The issue is a node version problem afaik, so the solution for me was to use Node V16 (via NVM). Updated project to later versions of Node don't seem to have the problem.

sonicviz avatar May 03 '24 04:05 sonicviz

For any who need to use a newer version of node and don't like the idea of using --openssl-legacy-provider, an alternative solution is to force a specific version of webpack and terser-webpack-plugin. See webpack issue for more details here.

"overrides": {
  "[email protected]": {
    "terser-webpack-plugin": "^4.2.3"
  }
}

In summary the root of this issue is that node 17^ doesn't support the md4 hashing algorithm. So any package which uses crypto.createHash('md4') will throw this error. Vuepress accepts older versions of webpack which use this algorithm by default. Also webpack depends on an outdated version of terser-webpack-plugin which also uses md4.

Hopefully that is merged soon and will help solve this issue. Then we can bump the version of webpack used here and it should be resolved without the need for an override.

This......... Thank you for posting.. I have been looking for a proper work around for ages. I can finally sleep now :)

Kerwood avatar May 06 '24 20:05 Kerwood

I'm using nodejs 18.16.0, npm 9.5.1, vuepress 1.9.10 in Windows 11. I can successfully run npm run dev, but get error running npm run build because Client compiling failed with this error (but why?) Setting NODE_OPTIONS works.

i had the same problem...I don't know if you still need an answer but for me works change the node version with nvm to node 16.20.0

I change node to 16.20.0, it works! Thx bro

EthanCh30 avatar Jun 13 '24 18:06 EthanCh30