When i try to start server, facing this problem:
[email protected] serve:ssr D:\PROGRAMIRANJE\CMSfrontbackup node dist/CMSfront/server/main.js
D:\PROGRAMIRANJE\CMSfrontbackup\dist\CMSfront\server\main.js:196764 throw new Error("package.json does not exist at " + package_json_path); ^
Error: package.json does not exist at D:\PROGRAMIRANJE\CMSfrontbackup\dist\CMSfront\package.json
at Object../node_modules/grpc/node_modules/node-pre-gyp/lib/pre-binding.js.exports.find (D:\PROGRAMIRANJE\CMSfrontbackup\dist\CMSfront\server\main.js:196764:15)
at Object../node_modules/grpc/src/grpc_extension.js (D:\PROGRAMIRANJE\CMSfrontbackup\dist\CMSfront\server\main.js:211850:12)
at webpack_require (D:\PROGRAMIRANJE\CMSfrontbackup\dist\CMSfront\server\main.js:20:30)
at Object../node_modules/grpc/src/client_interceptors.js (D:\PROGRAMIRANJE\CMSfrontbackup\dist\CMSfront\server\main.js:209576:12)
at webpack_require (D:\PROGRAMIRANJE\CMSfrontbackup\dist\CMSfront\server\main.js:20:30)
at Object../node_modules/grpc/src/client.js (D:\PROGRAMIRANJE\CMSfrontbackup\dist\CMSfront\server\main.js:208381:27)
at webpack_require (D:\PROGRAMIRANJE\CMSfrontbackup\dist\CMSfront\server\main.js:20:30)
at Object../node_modules/grpc/index.js (D:\PROGRAMIRANJE\CMSfrontbackup\dist\CMSfront\server\main.js:191024:14)
at webpack_require (D:\PROGRAMIRANJE\CMSfrontbackup\dist\CMSfront\server\main.js:20:30)
at Object../node_modules/@firebase/firestore/dist/index.node.cjs.js (D:\PROGRAMIRANJE\CMSfrontbackup\dist\CMSfront\server\main.js:118582:12)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] serve:ssr: node dist/CMSfront/server/main.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] serve:ssr script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\Lenovo Z50-70\AppData\Roaming\npm-cache_logs\2020-04-05T14_07_24_462Z-debug.log
I see bolded webpack_require but when i install nguniversal i dont get webpack config file. This is my timeline:
- ng add @nguniversal/express-engine
- npm run build:ssr
- npm run serve:ssr - error from top.
Pls help me solve this.
Edit: package.json
{
"name": "cmsfront",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"dev:ssr": "ng run CMSfront:serve-ssr",
"serve:ssr": "node dist/CMSfront/server/main.js",
"build:ssr": "ng build --prod && ng run CMSfront:server:production",
"prerender": "ng run CMSfront:prerender"
},
"private": true,
"dependencies": {
"@angular/animations": "~9.0.0",
"@angular/cdk": "^9.2.0",
"@angular/common": "~9.0.0",
"@angular/compiler": "~9.0.0",
"@angular/core": "~9.0.0",
"@angular/fire": "^5.4.2",
"@angular/forms": "~9.0.0",
"@angular/material": "^9.2.0",
"@angular/platform-browser": "~9.0.0",
"@angular/platform-browser-dynamic": "~9.0.0",
"@angular/platform-server": "~9.0.0",
"@angular/router": "~9.0.0",
"@nguniversal/express-engine": "^9.0.2",
"express": "^4.15.2",
"firebase": "^7.13.1",
"hammerjs": "^2.0.8",
"rxjs": "~6.5.4",
"tslib": "^1.10.0",
"zone.js": "~0.10.2"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.900.1",
"@angular/cli": "~9.0.1",
"@angular/compiler-cli": "~9.0.0",
"@angular/language-service": "~9.0.0",
"@nguniversal/builders": "^9.0.2",
"@types/express": "^4.17.0",
"@types/node": "^12.11.1",
"@types/jasmine": "~3.5.0",
"@types/jasminewd2": "~2.0.3",
"codelyzer": "^5.1.2",
"jasmine-core": "~3.5.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.3.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~2.1.0",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.2",
"protractor": "~5.4.3",
"ts-node": "~8.3.0",
"tslint": "~5.18.0",
"typescript": "~3.7.5"
}
}
angular.json
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"CMSfront": {
"projectType": "application",
"schematics": {
"@schematics/angular:component": {
"style": "scss"
}
},
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/CMSfront/browser",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json",
"aot": true,
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"./node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
"src/styles.scss"
],
"scripts": []
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "6kb",
"maximumError": "10kb"
}
]
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "CMSfront:build"
},
"configurations": {
"production": {
"browserTarget": "CMSfront:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "CMSfront:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.spec.json",
"karmaConfig": "karma.conf.js",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"./node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
"src/styles.scss"
],
"scripts": []
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"tsconfig.app.json",
"tsconfig.spec.json",
"e2e/tsconfig.json"
],
"exclude": [
"**/node_modules/**"
]
}
},
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "e2e/protractor.conf.js",
"devServerTarget": "CMSfront:serve"
},
"configurations": {
"production": {
"devServerTarget": "CMSfront:serve:production"
}
}
},
"server": {
"builder": "@angular-devkit/build-angular:server",
"options": {
"outputPath": "dist/CMSfront/server",
"main": "server.ts",
"tsConfig": "tsconfig.server.json"
},
"configurations": {
"production": {
"outputHashing": "media",
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"sourceMap": false,
"optimization": true
}
}
},
"serve-ssr": {
"builder": "@nguniversal/builders:ssr-dev-server",
"options": {
"browserTarget": "CMSfront:build",
"serverTarget": "CMSfront:server"
},
"configurations": {
"production": {
"browserTarget": "CMSfront:build:production",
"serverTarget": "CMSfront:server:production"
}
}
},
"prerender": {
"builder": "@nguniversal/builders:prerender",
"options": {
"browserTarget": "CMSfront:build:production",
"serverTarget": "CMSfront:server:production",
"routes": [
"/"
]
},
"configurations": {
"production": {}
}
}
}
}
},
"defaultProject": "CMSfront"
}