An npm script is a named command definition in the scripts field of package.json. It gives a project a consistent way to run development, build, watch, and test tools. section 9.2.2
...
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test"
},
...
A typical Angular package.json defines scripts that map short names to Angular CLI commands. section 9.2.2
Run a script with npm run followed by its name from the folder containing package.json. For example, npm run test executes the test definition; ng test produces the same result for this project. section 9.2.2
Common project scripts provide these operations:
- start runs the development server through ng serve. section 9.2.2
- build performs the production build process. section 9.2.2
- watch builds in development mode and watches for changes. section 9.2.2
- test starts the unit-testing tools. section 9.2.2
Adding a server command
After installing json-server locally, add a json script such as "json": "json-server --p 3500 restData.js". Run it from the exampleApp folder with npm run json to serve the configured data file on port 3500. section 23.1
Listing 23.2. Adding a script entry in the package.json file in the exampleApp folder
...
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test",
"json": "json-server --p 3500 restData.js"
},
...
The complete package.json change shows how a project combines standard Angular commands with a custom json-server command. section 23.1



