Когда я пытаюсь запустить сервер, сталкиваюсь с этой проблемой:
cmsfront@0.0.0 serve: ssr D: \ PROGRAMIRANJE \ CMSfrontbackup узел dist / CMSfront / server / main. js
D: \ PROGRAMIRANJE \ CMSfrontbackup \ dist \ CMSfront \ server \ main. js: 196764 throw new Error ("package. json не существует в" + package_json_path); ^
Ошибка: пакет. json не существует в D: \ PROGRAMIRANJE \ CMSfrontbackup \ dist \ CMSfront \ package. json в 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) в объекте ../ node_modules / grpc / src / grpc_extension . js (D: \ PROGRAMIRANJE \ CMSfrontbackup \ dist \ CMSfront \ server \ main. js: 211850: 12) в webpack_require (D: \ PROGRAMIRANJE \ CMSfrontbackup \ dist \ CMSfront \ server \ main. js: 20: 30) в Object ../ node_modules / grpc / src / client_interceptors. js (D: \ PROGRAMIRANJE \ CMSfrontbackup \ dist \ CMSfront \ server \ main. js: 209576: 12) в webpack_require (D: \ PROGRAMIRANJE \ CMSfrontbackup \ dist \ CMSfront \ server \ main. js: 20: 30) в Object ../ node_modules / grpc / src / client. js (D : \ PROGRAMIRANJE \ CMSfrontbackup \ dist \ CMSfront \ server \ main. js: 208381: 27) в webpack_require (D: \ PROGRAMIRANJE \ CMSfrontbackup \ dist \ CMSfront \ server \ main. js: 20:30) в Объец t ../ node_modules / grpc / index. js (D: \ PROGRAMIRANJE \ CMSfrontbackup \ dist \ CMSfront \ server \ main. js: 191024: 14) в webpack_require (D: \ PROGRAMIRANJE \ CMSfrontbackup \ dist \ CMSfront \ server \ main. js: 20: 30) на объекте ../ node_modules/@firebase/firestore/dist/index.node.cjs.js (D: \ PROGRAMIRANJE \ CMSfrontbackup \ dist \ CMSfront \ server \ main. js: 118582: 12)
npm ОШИБКА! код ELIFECYCLE npm ОШИБКА! errno 1 npm ERR! cmsfront@0.0.0 подача: ssr: node dist/CMSfront/server/main.js
npm ОШИБКА! Статус выхода 1 npm ERR! npm ОШИБКА! Не удалось выполнить скрипт cmsfront@0.0.0 serve: ssr. npm ОШИБКА! Это, вероятно, не проблема с npm. Скорее всего, выше вывод журнала.
npm ERR! Полный журнал этого прогона можно найти в: npm ERR! C: \ Users \ Lenovo Z50-70 \ AppData \ Roaming \ npm -cache_logs \ 2020-04-05T14_07_24_462Z-debug.log
Я вижу жирный шрифт webpack_require, но при установке nguniversal я не получить файл конфигурации webpack. Это моя временная шкала:
- ng add @ nguniversal / express -engine
- npm run build: ssr
- npm run serve: ssr - ошибка сверху.
Пожалуйста, помогите мне решить эту проблему.
Редактировать: пакет. 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"
}