I am following the guide from here on a nextjs application. Using VSCode on windows.
It says use the script: "dev": "NODE_OPTIONS='--inspect' next dev"
this results in:
'NODE_OPTIONS' is not recognized as an internal or external command, operable program or batch file.
Yes I know there is already a question with the same name but it is 2.5 years old, has 8k views and no accepted answer. I am unable to comment to add information to it. Feel free to mark this as a duplicate but please at least link it in a comment in the other question.
The one answer that is there advises installing yet another (maintenance mode) dependency and configuring it to change environment variables.
This and other research leads me to believe that there is an issue with environment variables here. Can't I just set them manually? Why is this not mentioned in the official next guide? How can I set the correct environment variable?
Two of the main reasons due to which you can encounter the above-mentioned error are: Node. js is not installed on your system. Environment variables are incorrectly set.
Either delete the path from user variable or correct the right path (C:\Program Files\nodejs). Restart CMD and it should work.
To solve the error "react-scripts is not recognized as an internal or external command, operable program or batch file", open your terminal in your project's root directory and install the react-scripts package by running npm install react-scripts and clear your npm cache if necessary. Copied!
There is a way to get it working and you can find a similar question posted here.
npm i cross-env --save-dev
Edit your package.json so the dev option looks like this
{
"scripts": {
"dev": "cross-env NODE_OPTIONS='--inspect' next dev",
"build": "next build",
"start": "next start"
}
}
You can now launch your NextJS program in a separate terminal. After that follow the NextJS VSCode debugging instructions. Attach VSCode to the running NextJS instance.
You're all set.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With