vuejs / vuepress

📝 Minimalistic Vue-powered static site generator
https://vuepress.vuejs.org
MIT License
22.43k stars 4.79k forks source link

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

Open maxfrischknecht opened 1 year ago

maxfrischknecht commented 1 year ago

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
lewissk commented 1 year ago

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.

maxfrischknecht commented 1 year ago

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

kingcwt commented 1 year ago
image

The current node version is 18.0.0

muang0 commented 9 months ago

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

sonicviz commented 9 months ago

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?

1gn0r4nd commented 6 months ago

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" }, }

guluguru commented 5 months ago

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",
Alex6357 commented 5 months ago

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.

DoryanPC commented 3 months ago

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

leiluspocus commented 2 months ago

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 🙏🏼

MrMarCode commented 1 month ago

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": {
  "webpack@4.47.0": {
    "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.

sonicviz commented 1 month ago

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.

Kerwood commented 1 month ago

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": {
  "webpack@4.47.0": {
    "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 :)

EthanCh30 commented 2 weeks ago

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