user2225263
user2225263

Reputation: 307

node.js on production server

I have written a website in angular2 and deploy the dist folder ( after compiling using webpack) on the AWS server. website works just fine. Now I am wondering why ?? because I have not installed node.js on the server neither I have deployed the node_modules folder than how come the website works just fine. In my VS code, I have to download packages using npm but on server, no package exist. kindly explain. It may sound a strange question but I am really confused Or missing some basics.

Upvotes: 2

Views: 702

Answers (3)

Shuja Ahmed
Shuja Ahmed

Reputation: 752

Below is the complete breakdown of files that are created after you run npm run build:prod:

  1. dist/main.[hash].bundle.js Your application bundled.
  2. dist/vendor.[hash].bundle.js Your dependencies (@angular, RxJS...) bundled
  3. dist/polyfill.[hash].bundle.js the polyfill dependencies (@angular, RxJS...) bundled .
  4. dist/index.html entry point of your application.
  5. dist/inline.[hash].bundle.js webpack loader
  6. dist/style.[hash].bundle.css the style definitions
  7. dist/assetsresources copied from the Angular CLI assets configuration.

Upvotes: 0

Ajk_P
Ajk_P

Reputation: 1874

Angular does not run on the server, but on the client instead.

The server simply sends the files to the client, so they can be run.

Therefore you really need nothing installed on the server. It is just there for delivery of the files.

EDIT: I guess it's worth mentioning that there is some tanspile/compile/pack steps that can happen on the server to make the distribution package readable by the clients javascript.

Upvotes: 1

Shuja Ahmed
Shuja Ahmed

Reputation: 752

Actually when you are creating your distribution folder by running a command similar to npm run build:prod all your code including required packages and libraries are compressed into minified files which is eventually deployed to the server. So thats how all your node_modules are still part of your code in the dist folder.

Upvotes: 1

Related Questions