netlify / cli

Netlify Command Line Interface
http://cli.netlify.com
MIT License
1.58k stars 358 forks source link

Netlify Dev Server doesn't start on Node 17.x/18.x #3617

Closed hrishikesh-k closed 2 years ago

hrishikesh-k commented 3 years ago

Describe the bug

Similar to this: https://github.com/netlify/cli/issues/2882#issue-939909811

Netlify Dev tries to start a server, it injects the environment variables, parses the configuration files and starts the local server of the framework, however it never starts the Netlify CLI's server.

Till now, the behaviour has been observed with Vite and Create React App (but more frameworks could be affected). This has been observed on MacOS 12. Other Operating Systems have not been checked.

This works with Node 14.17.5, possibly with any other Node version than Node 17.

To Reproduce:

  1. Use Node 17 (17.0.1 at the time of writing).
  2. Try running netlify dev in a project (possibly in a Vite or CRA project)
  3. See that the dev server never starts.

Configuration

  System:
    OS: macOS 12.0.1
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 891.31 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 17.0.1 - ~/.nvm/versions/node/v17.0.1/bin/node
    npm: 8.1.1 - ~/.nvm/versions/node/v17.0.1/bin/npm

Expected behaviour

The Netlify Dev server should start.

CLI Output

Vite:

◈ Netlify Dev ◈
◈ Ignored general context env var: LANG (defined in process)
◈ Starting Netlify Dev with vite

> dev
> vite

  vite v2.4.1 dev server running at:

  > Local: http://localhost:3000/
  > Network: use `--host` to expose

  ready in 217ms.

Additional context

Marked low-priority as there's a workaround to use a different Node version.

erezrokah commented 3 years ago

In case someone would like to pick this up, the line we wait for the framework server (e.g. Vite) is here: https://github.com/netlify/cli/blob/51e7b69dd8065b18081c564aeb6d1e225d83380a/src/commands/dev/index.js#L104

tinfoil-knight commented 3 years ago

@erezrokah This might be related to https://github.com/vitejs/vite/issues/5365? As per the organisation member:

In the current state, we don't support node 17 right now.

erezrokah commented 3 years ago

@tinfoil-knight woo - great find.

This was also reported for create-react-app on the related issue.

@LuskeyNoah does reverting to Node.js < 17 work for you? This will help us confirm if this is a Vite specific issue or not.

hrishikesh-k commented 3 years ago

I just created a bare CRA project and it doesn't seem to be working with Node 17 at all. Here's the log:

npx netlify dev
◈ Netlify Dev ◈
◈ Starting Netlify Dev with Create React App

> my-app@0.1.0 start
> react-scripts start

ℹ 「wds」: Project is running at http://192.168.0.109/
ℹ 「wds」: webpack output is served from 
ℹ 「wds」: Content not from webpack is served from /Users/hrishikesh/Desktop/my-app/public
ℹ 「wds」: 404s will fallback to /
Starting the development server...

Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:67:19)
    at Object.createHash (node:crypto:130:10)
    at module.exports (/Users/hrishikesh/Desktop/my-app/node_modules/webpack/lib/util/createHash.js:135:53)
    at NormalModule._initBuildHash (/Users/hrishikesh/Desktop/my-app/node_modules/webpack/lib/NormalModule.js:417:16)
    at handleParseError (/Users/hrishikesh/Desktop/my-app/node_modules/webpack/lib/NormalModule.js:471:10)
    at /Users/hrishikesh/Desktop/my-app/node_modules/webpack/lib/NormalModule.js:503:5
    at /Users/hrishikesh/Desktop/my-app/node_modules/webpack/lib/NormalModule.js:358:12
    at /Users/hrishikesh/Desktop/my-app/node_modules/loader-runner/lib/LoaderRunner.js:373:3
    at iterateNormalLoaders (/Users/hrishikesh/Desktop/my-app/node_modules/loader-runner/lib/LoaderRunner.js:214:10)
    at iterateNormalLoaders (/Users/hrishikesh/Desktop/my-app/node_modules/loader-runner/lib/LoaderRunner.js:221:10)
/Users/hrishikesh/Desktop/my-app/node_modules/react-scripts/scripts/start.js:19
  throw err;
  ^

Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:67:19)
    at Object.createHash (node:crypto:130:10)
    at module.exports (/Users/hrishikesh/Desktop/my-app/node_modules/webpack/lib/util/createHash.js:135:53)
    at NormalModule._initBuildHash (/Users/hrishikesh/Desktop/my-app/node_modules/webpack/lib/NormalModule.js:417:16)
    at /Users/hrishikesh/Desktop/my-app/node_modules/webpack/lib/NormalModule.js:452:10
    at /Users/hrishikesh/Desktop/my-app/node_modules/webpack/lib/NormalModule.js:323:13
    at /Users/hrishikesh/Desktop/my-app/node_modules/loader-runner/lib/LoaderRunner.js:367:11
    at /Users/hrishikesh/Desktop/my-app/node_modules/loader-runner/lib/LoaderRunner.js:233:18
    at context.callback (/Users/hrishikesh/Desktop/my-app/node_modules/loader-runner/lib/LoaderRunner.js:111:13)
    at /Users/hrishikesh/Desktop/my-app/node_modules/babel-loader/lib/index.js:59:103 {
  opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
  library: 'digital envelope routines',
  reason: 'unsupported',
  code: 'ERR_OSSL_EVP_UNSUPPORTED'
}

Node.js v17.0.1
◈ Command failed with exit code 1: npm run start. Shutting down Netlify Dev server

Doesn't seem to be related to CLI. The setup works with Node 16. I believe this is because Webpack doesn't play well with Node 17 yet.

ryansburgoyne commented 3 years ago

I have encountered this as well with a Hugo site: https://answers.netlify.com/t/netlify-dev-server-not-starting-for-hugo-site/47222

One interesting bit is that it works the first time I try after rebooting my machine (I have to navigate to the Hugo-launched page first, and that will trigger it to launch the Netlify server on port 8888), but after killing the server I can't get it back up again without rebooting.

After installing Node v16, it is working as expected. I don't even have to navigate to the Hugo-launched port.

LuskeyNoah commented 2 years ago

@LuskeyNoah does reverting to Node.js < 17 work for you? This will help us confirm if this is a Vite specific issue or not.

Yes, reverting to node 16 LTS fixes the issue for me.

erezrokah commented 2 years ago

Reported for Vue too in https://github.com/netlify/cli/issues/3772

MincePie commented 2 years ago

Is this still current?

tkrunning commented 2 years ago

@MincePie Yes, seems so. With netlify-cli version 9.16.3 and node v17.9.0 the dev server is still not starting for me when running netlify dev (for a Jekyll project). Works fine with v16.13.2.

robvanderleek commented 2 years ago

Also bumped into this problem recently and reverted Node to v16. FWIW this is how to downgrade to Node 16.x on macOS with Brew:

brew uninstall --ignore-dependencies node
brew install node@16
brew link node@16
SeanCassiere commented 2 years ago

Can confirm that this issue also persists on Node 18 as well.

My app uses create-react-app, and like the others on Node@17 (and above including 18), the local webpack server starts, however, the Netlify Dev server (localhost:8888) does not. (Both the react-app content and the functions are not available at 8888)

seanc ⋊> ~/c/nav-credit-card-update git:(main) node -v                                                                                                                                                                                11:49:22
v18.0.0
seanc ⋊> ~/c/nav-credit-card-update git:(main) netlify dev                                                                                                                                                                            11:49:24
◈ Netlify Dev ◈
◈ Ignored build settings env var: REACT_APP_API_BASE_URL_V3 (defined in .env file)
◈ Injected .env file env var: REACT_APP_API_BASE_URL_V3
◈ Ignored build settings env var: V3_AUTH_URL (defined in .env file)
◈ Injected .env file env var: V3_AUTH_URL
◈ Ignored build settings env var: V3_CLIENT_ID (defined in .env file)
◈ Injected .env file env var: V3_CLIENT_ID
◈ Ignored build settings env var: V3_CLIENT_SECRET (defined in .env file)
◈ Injected .env file env var: V3_CLIENT_SECRET
◈ Ignored build settings env var: REACT_APP_QA_API_BASE_URL_V3 (defined in .env file)
◈ Injected .env file env var: REACT_APP_QA_API_BASE_URL_V3
◈ Ignored build settings env var: QA_V3_AUTH_URL (defined in .env file)
◈ Injected .env file env var: QA_V3_AUTH_URL
◈ Ignored build settings env var: QA_V3_CLIENT_ID (defined in .env file)
◈ Injected .env file env var: QA_V3_CLIENT_ID
◈ Ignored build settings env var: QA_V3_CLIENT_SECRET (defined in .env file)
◈ Injected .env file env var: QA_V3_CLIENT_SECRET
◈ Injected .env file env var: REACT_APP_API_BASE_URL
◈ Injected .env file env var: REACT_APP_V3_AUTH_URL
◈ Injected .env file env var: REACT_APP_DEVELOPMENT
◈ Injected .env file env var: SERVER_PORT
◈ Loaded function GetTokenV3 http://localhost:8888/.netlify/functions/GetTokenV3.
◈ Functions server is listening on 57852
◈ Starting Netlify Dev with Create React App
yarn run v1.22.18
$ react-scripts start
ℹ 「wds」: Project is running at http://0.0.0.0:3000/
ℹ 「wds」: webpack output is served from 
ℹ 「wds」: Content not from webpack is served from /Users/seanc/code/nav-credit-card-update/public
ℹ 「wds」: 404s will fallback to /
Starting the development server...

Compiled successfully!

You can now view nav-reservation-cc-update in the browser.

  http://localhost:3000

Note that the development build is not optimized.
To create a production build, use yarn build.
jgrizou commented 2 years ago

Wow glad I found this, it was driving me nuts. Using an empty base Astro project, netlify dev was not plumbing functions correctly.

I downgraded to node16 and it works now. If you are using conda, this one is 16.13.1: conda install -c anaconda nodejs from https://anaconda.org/anaconda/nodejs

That issue would gain being advertised more widely and if possible a test in netlify cli added to inform users of the issue.

Thanks for sharing!

hrishikesh-k commented 2 years ago

Just came back to say that this seems to be the case for Node 18 too. It doesn't work reliably. I thought someone else might have reported by now, but since no one had, just adding a note here.

EDIT: I noticed someone else has noted this above.

agnescameron commented 2 years ago

also having this issue with node 18!

Kirbyasdf commented 2 years ago

Its rekt for me too....lets get it going @sw-yx

mosesoak commented 2 years ago

Fails for us using nvm with the following:

3:37:20 PM: Python version set to 2.7
3:37:20 PM: Attempting node version '18' from .nvmrc
3:37:21 PM: Downloading and installing node v18.5.0...
3:37:21 PM: Downloading https://nodejs.org/dist/v18.5.0/node-v18.5.0-linux-x64.tar.xz...
3:37:22 PM: Computing checksum with sha256sum
3:37:22 PM: Checksums matched!
3:37:24 PM: node: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.27' not found (required by node)
node: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.25' not found (required by node)
node: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found (required by node)
nvm is not compatible with the npm config "prefix" option: currently set to ""
3:37:24 PM: Run `nvm use --delete-prefix v18.5.0` to unset it.
3:37:24 PM: Failed to install node version '18'
pedroarthuralvesdeoliveira commented 1 year ago

Hey, guys, what's up? I am getting this error too... Even using Node LTS version or the latest now (19.7.0)

hrishikesh-k commented 1 year ago

Note 18 is working fine, I haven't checked with Node 19 yet. Could you share the output you get when running netlify dev in Node 18 environment?

pedroarthuralvesdeoliveira commented 1 year ago

Actually, when I run the functions in dev mode, I get this errors: image image

The structure folder: image

The netlify.toml image

hrishikesh-k commented 1 year ago

Doesn't see related to this issue. Please open another one or write in Netlify Forums: https://answers.netlify.com/

1-800-jono commented 1 year ago

In Gatsby v4 and Node v18. Running netlify dev gets stuck in Waiting for framework port 8000. This can be configured using the 'targetPort' property in the netlify.toml