简体   繁体   中英

Which are the js files that are being run when I run “npm start”?

I am trying to pick up angularjs v2 using the official documentation provided.

I followed the instructions on this page.

https://angular.io/docs/ts/latest/guide/setup.html

After I run npm start , I see a webpage http://localhost:3000/ being launched automatically on my default browser.

I see several js files in the quickstart folder. Which are the js files that are being run and in what sequence? Is there a main file that tells npm which files to run for npm start ? How does npm knows which files to run?

In your package.json file there will be a "script" named "start". The one you are running from is found here: https://github.com/angular/quickstart/blob/master/package.json

"start": "tsc && concurrently \"tsc -w\" \"lite-server\" ",

It is executing the command tsc && concurrently "tsc -w" "lite-server"

For usage of the tsc and concurrently node packages check out npmjs.com:

您可以在每个文件上发出一个alert(“ file name”)来查看哪个文件最先运行或console.log(“ file name”);

From npm help start

This runs an arbitrary command specified in the package's "start" property of its "scripts" object. If no "start" property is specified on the "scripts" object, it will run node server.js.

So open package.json

"scripts": {
  "test": "echo \"Error: no test specified\" && exit 1"
},

Just add something to it.

"scripts": {
  "test": "echo \"Error: no test specified\" && exit 1",
  "start": "arbitrary command"
},

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM