Encountering an error while compiling the Angular code for prerendering:
ERROR in prerender.ts(7,62): error TS2307: Cannot find module './dist-prerender/main.bundle'
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `ng build && ng build --project prerender --output-hashing=none`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build 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! /root/.npm/_logs/2019-06-12T07_43_21_717Z-debug.log
Seems like the main.bundle file is not generated by my application
I have made changes to angular.json for prerendering
angular.json
"prerender" : {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"prefix": "app",
"schematics": {},
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:server",
"options": {
"outputPath": "dist-prerender",
"main": "main.prerender.ts",
"tsConfig": "tsconfig.prerender.json"
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true
}
}}
}`
tsconfig.prerender.json
{
"extends": "./tsconfig.app.json",
"compilerOptions": {
"outDir": "../out-tsc/prerender",
/* node only understands commonjs for now*/
"module": "commonjs"
},
"exclude": [
"test.ts",
"**/*.spec.ts"
],
"angularCompilerOptions": {
"entryModule": "app/app.prerender.module#AppPrerenderModule"
}
}