Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'NODE_OPTIONS' is not recognized as an internal or external command - still an issue

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?

like image 536
user3190036 Avatar asked Jun 15 '21 21:06

user3190036


People also ask

Why node is not recognized as an internal or external command?

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.

How do you fix npm is not recognized?

Either delete the path from user variable or correct the right path (C:\Program Files\nodejs). Restart CMD and it should work.

Is not recognized as an internal or external command npm run?

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!


Video Answer


1 Answers

There is a way to get it working and you can find a similar question posted here.

Step 1

npm i cross-env --save-dev

Step 2

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

Step 3

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.

like image 153
zachbugay Avatar answered Oct 05 '22 23:10

zachbugay