23

After cloning the repository I created and set my .env.local file, ran npm i then ran npm run dev. The server starts, env is loaded from .env.local however it immediately fails prompting me with the following:

error - Failed to load next.config.js, see more info here https://nextjs.org/docs/messages/next-config-error
Error: Not supported
    at Object.loadConfig [as default] (C:\Users\Nick\Desktop\rebuild\node_modules\next\dist\server\config.js:399:74)
    at async NextServer.loadConfig (C:\Users\Nick\Desktop\rebuild\node_modules\next\dist\server\next.js:110:22)
    at async NextServer.prepare (C:\Users\Nick\Desktop\rebuild\node_modules\next\dist\server\next.js:92:24)
    at async C:\Users\Nick\Desktop\rebuild\node_modules\next\dist\cli\next-dev.js:126:9
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! rebuild@0.1.0 dev: `next dev`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the rebuild@0.1.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Nick\AppData\Roaming\npm-cache\_logs\2021-10-29T19_47_30_427Z-debug.log

The NextJS documentation says: See the error message in your terminal where you started next to see more context. however all it is telling me is Not Supported.

I'm not familiar with the error and was looking for guidance.

Nick
  • 1,471
  • 2
  • 21
  • 35
  • It's happening to me too. Post it as an answer if you've found one. It used to run fine on windows. I just installed Ubuntu, and this exact error pops up. – Nike Lepz Oct 30 '21 at 07:40
  • Perhaps that's because of the breaking change of [Next.js 12](https://nextjs.org/blog/next-12)? The repo was updated four days ago. You can probably try downgrading. – Nicholas Oct 30 '21 at 10:54

3 Answers3

40

I ended up uninstalling Node and everything related to it. Reinstalled with Node v14.0.0 and it seemed to work.

Thanks all for your help!

Nick
  • 1,471
  • 2
  • 21
  • 35
  • Had the same issue on ubuntu. I upgraded nodesj to the latest version (see https://askubuntu.com/a/480642). Then it worked again. – hawkpatrick Nov 03 '21 at 15:11
  • If you need to change your node version a lot, I recommend using nvm. Instead of needing to uninstall and install another version, you can just use one command to alter your node version https://github.com/nvm-sh/nvm – Guilherme Samuel Feb 07 '22 at 13:58
  • Worked for me I was using v12^ I reinstalled to 18^ it worked – Mahi Tej Gvp Oct 27 '22 at 13:36
  • I'm using node v10, but upgrading to v14 works for me, and i not needed install jemalloc and sharp. Builds run success! – Edward Ramos Nov 07 '22 at 12:45
17

I solved this by upgrading to the latest version of nodeJS

Niana
  • 1,057
  • 2
  • 14
  • 42
5

This error Error: Not supported is likely coming up because the installed Node.js version is not supported by the used Next.js version.

e.g. Next.js v12 doesn't support Node.js v10:

The minimum Node.js version has been bumped from 12.0.0 to 12.22.0, which is the first version of Node.js with native ES modules support

This version discrepancy can arise for several reasons, sometimes quite unexpected, and also seemingly "out of nowhere", because not only a "wrong" Node.js version can be installed, but also different Node.js versions can be installed in different paths.

Solutions:

(Note that after the below solutions you also might need to delete the folders .next and node_modules, and re-install the node modules again, e.g. yarn or npm install).

1. different computer

If you pull the repository on a different computer, where a different Node.js version is installed:

Solution: update Node.js to the supported version.

2. different environment

If you build the repository inside a different environment, where a different Node.js version is referenced (e.g. in Webstorm vs. a separate Terminal):

Solution: make sure you are using the correct environment, or use the correct path to Node.js, or update Node.js.

3. different build commands

If you use different build commands, which do or do not specify a (absolute) path to a specific node.js installation:

  • e.g. /usr/bin/node ... --> use absolute path to specific node.js installation.
  • e.g. node ... --> use node installation as specified in the $PATH environment variable, e.g. /home/(username)/.nvm/versions/node/v14.18.1/bin/node.

Solution: Modify the build script to use the correct path to Node.js, or update the Node.js version under the used path.

4. broken build setup

If for some reason the build setup in Webstorm gets lost or breaks, which apparently can happen sometimes, e.g. when switching branches:

(You can verify this by trying to build inside a separate terminal.)

Solution: Fix the build setup in Webstorm to use the correct Note.js path, or update Node.js under the used path.

kca
  • 4,856
  • 1
  • 20
  • 41