Sub-command doesn't been reconize by system

80 Views Asked by At

In my package.json, I have this scripts:

"scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "build-dev": "nodemon -e ts,html -w ./src -x 'npm run build && gulp dist'",
    "watch": "ng build --watch --configuration development", 
    "test": "ng test"
}

Now when I run npm run ng build, get the error during execution of npm run build, it say 'npm' is not recognized as an internal command or external, an executable program or a batch file, but the first npm run build-dev works fine

Help me resolve the error, to make the command works

Update: I have finally resolve it, the problem was that package.json doesn't reconize the "'" symbol, so the error return is :''npm' is not recognized as an internal command or external, an executable program or a batch file and not 'npm' is not recognized as an internal command or external, an executable program or a batch file. So I resolved it, by using " by view this post,

"scripts": {
            "ng": "ng",
            "start": "ng serve",
            "build": "ng build",
            "build-dev": "nodemon -e ts,html -w ./src -x \"npm run build && gulp dist\"",
            "watch": "ng build --watch --configuration development", 
            "test": "ng test"
} 
2

There are 2 best solutions below

0
On

It seems like your path variables not configured properly to make sure type npm in the console and check the output if it says not recognized then you have you configure npm. For reference check this

0
On

You should run npm run build.

The syntax is npm run + alias, where alias is defined in package.json. i.e build-dev is alias of nodemon -e ts,html -w ./src -x 'npm run build && gulp dist'