Is node_modules and package.json is need for running dist folder in angular

Viewed 895

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" } }

2 Answers

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

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.

Related