Reputation: 1541
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! [email protected] dev: `next dev`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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.
Upvotes: 24
Views: 58989
Reputation: 6046
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.
(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
).
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.
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.
If you use different build commands, which do or do not specify a (absolute) path to a specific node.js installation:
/usr/bin/node ...
--> use absolute path to specific node.js installation.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.
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.
Upvotes: 5
Reputation: 1541
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!
Upvotes: 40