2

in my project, I just deleted every file except the dist folder and server.js but when I npm start it saying package.json & node_modules are needed. so my question is I only need the dist folder and server.js, not the other 2 folders is it possible?

I think you guys understand my question if not comment on it I will answer ASAP

package.json { "name": "ncmsui", "version": "0.0.0", "scripts": { "ng": "ng", "start": "node server.js", "build": "ng build", "test": "ng test", "lint": "ng lint", "e2e": "ng e2e" }, "private": true, "dependencies": { "@angular/animations": "~10.2.0", "@angular/cdk": "^11.2.0", "@angular/common": "~10.2.0", "@angular/compiler": "~10.2.0", "@angular/core": "~10.2.0", "@angular/flex-layout": "^11.0.0-beta.33", "@angular/forms": "~10.2.0", "@angular/material": "^10.2.7", "@angular/platform-browser": "~10.2.0", "@angular/platform-browser-dynamic": "~10.2.0", "@angular/router": "~10.2.0", "ag-grid-angular": "^24.0.0", "ag-grid-community": "^24.0.0", "ag-grid-enterprise": "^24.0.0", "rxjs": "~6.6.0", "tslib": "^2.0.0", "zone.js": "~0.10.2" }, "devDependencies": { "@angular-devkit/build-angular": "~0.1002.0", "@angular/cli": "~10.2.0", "@angular/compiler-cli": "~10.2.0", "@types/node": "^12.11.1", "@types/jasmine": "~3.5.0", "@types/jasminewd2": "~2.0.3", "codelyzer": "^6.0.0", "jasmine-core": "~3.6.0", "jasmine-spec-reporter": "~5.0.0", "karma": "~5.0.0", "karma-chrome-launcher": "~3.1.0", "karma-coverage-istanbul-reporter": "~3.0.2", "karma-jasmine": "~4.0.0", "karma-jasmine-html-reporter": "^1.5.0", "protractor": "~7.0.0", "ts-node": "~8.3.0", "tslint": "~6.1.0", "typescript": "~4.0.2" } }

Abru007
  • 435
  • 4
  • 12
  • please post your package.json file – batman567 Mar 24 '21 at 13:50
  • @batman567 here it is – Abru007 Mar 24 '21 at 14:07
  • 1
    in this config ```npm run start``` will launch ```node server.js```. as answered below - yes - you will then require node_modules and package.json. contents of your ```dist``` folder is irrelevant – batman567 Mar 24 '21 at 14:10
  • so the conclusion is that I can't ignore node_modules and package.json. Or is there is any way – Abru007 Mar 24 '21 at 14:15
  • i remember on AngularJS you could run ```ng serve:dist```. not sure if that came out of the box or whether we built that - but that would run the app from dist folder. you can look around for something similar in Angular 10 – batman567 Mar 24 '21 at 14:46
  • guys found the perfect solution [there is it](https://stackoverflow.com/a/49236585/14299858) – Abru007 Mar 24 '21 at 15:00
  • cool - well done. just out of interest - is this an angular or nodejs project? i see signs of both... – batman567 Mar 24 '21 at 15:06
  • @batman567 it's an angular project. thanks guys !! – Abru007 Mar 24 '21 at 15:08

2 Answers2

2

At least for Angular apps, angular-http-server seems to be a nicer option.

First install it with your preferred package manager, say

npm install angular-http-server -g
Syscall
  • 19,327
  • 10
  • 37
  • 52
0

To run your project local/dev you need node_modules and package.json.

Now just with the dist folder and server.js you can run your project on the could, like Heroku or Aws, because they will provide the correct node environment for your application to run.