Angular library compilation with file changes issue - node.js

I have a library on angular 12 which when served, watches for changes and automatically triggers the build again. My script for automatically building the library is:
ng build library --watch.
The issue is after building successfully, the automatic build triggers every minute even when no changes are made to any file.
My package.json:
{
"name": "test-library",
"version": "1.0.0-1",
"scripts": {
"ver": "genversion --es6 --semi ./libs/ui/src/lib/version-number/version-number.model.ts",
"ng": "ng",
"serve": "ng build library --watch",
"build": "ng build library --configuration production",
"npm-publish": "node cleanPackage.js && npm publish dist"
},
"peerDependencies": {
"#agm/core": "^3.0.0-beta.0",
"core-js": "^3.16.2",
"date-fns": "2.23.0",
"hammerjs": "^2.0.8",
"ng2-validation": "^4.2.0",
"rxjs": "~6.5.2",
"#angular/animations": "^12.2.5",
"#angular/cdk": "^12.2.5",
"#angular/common": "~12.2.5",
"#angular/compiler": "~12.2.5",
"#angular/core": "~12.2.5",
"#angular/forms": "~12.2.5",
"#angular/material": "^12.2.5",
"#angular/material-moment-adapter": "^12.2.5",
"#angular/platform-browser": "~12.2.5",
"#angular/platform-browser-dynamic": "~12.2.5",
"#angular/router": "~12.2.5",
"#angular/service-worker": "~12.2.5",
"#ngrx/effects": "12.4.0",
"#ngrx/router-store": "12.4.0",
"#ngrx/store": "12.4.0",
"#ngrx/store-devtools": "12.4.0",
"zone.js": "~0.11.4"
},
"devDependencies": {
"#agm/core": "^3.0.0-beta.0",
"#angular-devkit/build-angular": "~12.2.5",
"#angular/animations": "^12.2.5",
"#angular/cdk": "^12.2.5",
"#angular/cli": "~12.2.5",
"#angular/common": "~12.2.5",
"#angular/compiler": "~12.2.5",
"#angular/compiler-cli": "~12.2.5",
"#angular/core": "~12.2.5",
"#angular/forms": "~12.2.5",
"#angular/language-service": "~12.2.5",
"#angular/material": "^12.2.5",
"#angular/material-moment-adapter": "^12.2.5",
"#angular/platform-browser": "~12.2.5",
"#angular/platform-browser-dynamic": "~12.2.5",
"#angular/router": "~12.2.5",
"#angular/service-worker": "~12.2.5",
"#angularclass/hmr": "^3.0.0",
"#fortawesome/angular-fontawesome": "^0.8.2",
"#fortawesome/fontawesome-svg-core": "^1.2.36",
"#fortawesome/free-brands-svg-icons": "^5.15.4",
"#fortawesome/free-regular-svg-icons": "^5.15.4",
"#fortawesome/free-solid-svg-icons": "^5.15.4",
"#ks89/angular-modal-gallery": "^7.2.5",
"#ngrx/effects": "12.4.0",
"#ngrx/router-store": "12.4.0",
"#ngrx/store": "12.4.0",
"#ngrx/store-devtools": "12.4.0",
"#types/google-maps": "^3.2.0",
"#types/googlemaps": "3.39.13",
"#types/hammerjs": "^2.0.36",
"#types/jest": "25.1.4",
"#types/node": "^12.11.1",
"angular-cc-library": "^2.1.2",
"angular-svg-round-progressbar": "^6.0.1",
"chart.js": "^2.5.0",
"codelyzer": "^6.0.0",
"core-js": "^3.16.2",
"cypress": "^5.1.0",
"date-fns": "2.23.0",
"dotenv": "6.2.0",
"edit-json-file": "^1.6.0",
"genversion": "^2.2.1",
"hammerjs": "^2.0.8",
"jest": "^27.0.0",
"jest-preset-angular": "9.0.6",
"lodash.isequal": "4.5.0",
"mousetrap": "^1.6.5",
"ng-packagr": "^12.2.1",
"ng-samurai": "^2.0.6",
"ng2-charts": "^2.2.3",
"ng2-validation": "^4.2.0",
"prettier": "^2.0.4",
"rxjs": "~6.5.2",
"signature_pad": "^3.0.0-beta.4",
"ts-jest": "~27.0.5",
"ts-node": "~7.0.0",
"tslib": "^2.0.0",
"tslint": "~6.1.0",
"typescript": "~4.3.5",
"zone.js": "~0.11.4"
}
}
My angular.json:
{
"$schema": "./node_modules/#angular/cli/lib/config/schema.json",
"version": 1,
"projects": {
"web": {
"projectType": "library",
"root": "",
"sourceRoot": "src",
"prefix": "fin",
"architect": {
"build": {
"builder": "#angular-devkit/build-angular:ng-packagr",
"options": {
"tsConfig": "tsconfig.lib.json",
"project": "ng-package.json"
},
"configurations": {
"production": {
"tsConfig": "tsconfig.lib.prod.json"
}
}
},
"test": {
"builder": "#angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"tsConfig": "tsconfig.spec.json",
"karmaConfig": "karma.conf.js"
}
},
"lint": {
"builder": "#angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"tsconfig.lib.json",
"tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
}
},
"defaultProject": "web",
"cli": {
"defaultCollection": "#nrwl/angular",
"analytics": false
},
"schematics": {
"#nrwl/angular:application": {
"unitTestRunner": "jest",
"e2eTestRunner": "cypress"
},
"#nrwl/angular:library": {
"unitTestRunner": "jest"
},
"#nrwl/angular:component": {
"styleext": "scss"
}
}
}
I have projects that use this library and when the library builds every minute it triggers a build on the project as well making it to reload. This is really tough especially when debugging things on the project. I don't know what's the issue here and any help is appreciated.
Please let me know if you need any additional info.

Related

"Cannot GET /" error when running angular application on docker container

I'm trying to run a Angular App on docker, but when I try to access some page, I get this error.
I've tried to change the aot to false at angular.json, but it didn't work.
Here is my Dockerfile:
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install -g #angular/cli
RUN npm install
COPY . ./
RUN npm run build
EXPOSE 8080
CMD [ "node", "server.js" ]
and here is my package.json:
{
"name": "app-name",
"version": "0.0.2",
"scripts": {
"ng": "ng",
"start": "ng serve --host 0.0.0.0",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"update": "ncu -u -x firebase,#angular/fire"
},
"private": true,
"dependencies": {
"#angular/animations": "^14.0.0",
"#angular/cdk": "~14.0.0",
"#angular/common": "~14.0.0",
"#angular/compiler": "~14.0.0",
"#angular/core": "~14.0.0",
"#angular/fire": "^7.3.0",
"#angular/flex-layout": "^13.0.0-beta.38",
"#angular/forms": "~14.0.0",
"#angular/material": "^14.0.0",
"#angular/platform-browser": "~14.0.0",
"#angular/platform-browser-dynamic": "~14.0.0",
"#angular/pwa": "^14.0.0",
"#angular/router": "~14.0.0",
"#angular/service-worker": "~14.0.0",
"#fortawesome/angular-fontawesome": "^0.11.0",
"#fortawesome/fontawesome-svg-core": "^6.1.1",
"#fortawesome/free-solid-svg-icons": "^6.1.1",
"#ngx-translate/core": "^14.0.0",
"#ngx-translate/http-loader": "^7.0.0",
"bootstrap": "^5.1.3",
"crypto-js": "^4.1.1",
"file-saver": "^2.0.5",
"firebase": "^8.10.0",
"jwt-decode": "^3.1.2",
"material-design-icons": "^3.0.1",
"ng2-pdf-viewer": "^9.0.0",
"ngx-mask": "^14.0.0",
"ngx-toastr": "^14.3.0",
"rxjs": "^7.5.5",
"tslib": "^2.4.0",
"zone.js": "^0.11.5"
},
"devDependencies": {
"#angular-devkit/build-angular": "^14.0.0",
"#angular/cli": "~14.0.0",
"#angular/compiler-cli": "~14.0.0",
"#angular/language-service": "~14.0.0",
"#types/crypto-js": "^4.1.1",
"#types/jasmine": "~4.0.3",
"#types/jasminewd2": "~2.0.10",
"#types/node": "~17.0.40",
"codelyzer": "^6.0.2",
"jasmine-core": "~4.1.1",
"jasmine-spec-reporter": "~7.0.0",
"karma": "~6.3.20",
"karma-chrome-launcher": "~3.1.1",
"karma-coverage-istanbul-reporter": "~3.0.3",
"karma-jasmine": "~5.0.1",
"karma-jasmine-html-reporter": "^2.0.0",
"protractor": "~7.0.0",
"ts-node": "~10.8.1",
"tslint": "^6.1.3",
"typescript": "^4.7.3"
}
}
If anyone has already faced this error and knows how to solve it, I would greatly appreciate it, thanks.
I solved the problem using the useHash: true on my app-routing.module.ts.
Now I got link like something.com/#/someParameter
#NgModule({
imports: [RouterModule.forRoot(routes, {relativeLinkResolution: 'legacy', useHash: true})],
exports: [RouterModule]
})
export class AppRoutingModule {
}

Ng serve is working but ionic serve is failing

I'm building an app using Ionic 6.19.0 and it suddenly started to face building issues.
I get Error: spawn UNKNOWN each time I execute ionic serve.
This is my package.json file
{
"name": "stile",
"version": "0.0.1",
"author": "Ionic Framework",
"homepage": "https://ionicframework.com/",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"#angular-devkit/schematics": "^13.3.3",
"#angular/common": "~13.0.0",
"#angular/core": "~13.0.0",
"#angular/forms": "~13.0.0",
"#angular/platform-browser": "~13.0.0",
"#angular/platform-browser-dynamic": "~13.0.0",
"#angular/router": "~13.0.0",
"#auth0/angular-jwt": "^5.0.2",
"#capacitor/android": "3.4.3",
"#capacitor/app": "1.1.0",
"#capacitor/camera": "^1.3.1",
"#capacitor/core": "3.4.0",
"#capacitor/haptics": "1.1.4",
"#capacitor/keyboard": "1.2.1",
"#capacitor/status-bar": "1.0.7",
"#ionic/angular": "^6.0.0",
"#npmcli/node-gyp": "^2.0.0",
"bootstrap": "^5.1.3",
"install": "^0.13.0",
"jquery": "^3.6.0",
"json-server": "^0.17.0",
"node-sass": "^7.0.1",
"npm": "^8.6.0",
"rxjs": "~6.6.0",
"tslib": "^2.3.1",
"zone.js": "~0.11.4"
},
"devDependencies": {
"#angular-devkit/build-angular": "^13.3.3",
"#angular-eslint/builder": "^12.2.1",
"#angular-eslint/eslint-plugin": "~13.0.1",
"#angular-eslint/eslint-plugin-template": "~13.0.1",
"#angular-eslint/template-parser": "~13.0.1",
"#angular/cli": "~13.0.1",
"#angular/compiler": "~13.0.0",
"#angular/compiler-cli": "~13.0.0",
"#angular/language-service": "~13.0.0",
"#capacitor/cli": "3.4.0",
"#ionic/angular-toolkit": "^6.1.0",
"#popperjs/core": "^2.11.5",
"#types/jasmine": "~3.6.0",
"#types/jasminewd2": "~2.0.3",
"#types/node": "^12.11.1",
"#typescript-eslint/eslint-plugin": "5.3.0",
"#typescript-eslint/parser": "5.3.0",
"acorn": "^8.7.0",
"ajv": "^6.12.6",
"eslint": "^7.6.0",
"eslint-plugin-import": "2.22.1",
"eslint-plugin-jsdoc": "30.7.6",
"eslint-plugin-prefer-arrow": "1.2.2",
"jasmine-core": "~3.8.0",
"jasmine-spec-reporter": "~5.0.0",
"karma": "~6.3.2",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.0.3",
"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",
"typescript": "~4.4.4"
},
"description": "An Ionic project"
}
Here are few solutions that might help:
Ensure you're in the root folder of your project.
Try fixing the existing node_modules folder with npm rebuild + reassign
permissions to your node_modules folder: chmod 755 -R
/path/to/node_modules
Remove node_modules and reinstall with npm install

dependencies in the wrong place with yarn

When I do yarn install && yarn workspace frontend install && yarn workspace backend install in my Typescript project (various package.json files below) the dependencies for (e.g.) Angular and CDK are all in the root node_modules folder, but when I run (e.g.) yarn workspace frontend ng build, I get An unhandled exception occurred: ENOENT: no such file or directory, lstat '/work/frontend/node_modules/#angular'. How do I get the dependencies in the right place?
Root package.json:
"name": "load-tester",
"version": "1.0.0",
"private": true,
"workspaces": [
"backend",
"frontend"
],
"scripts": {
"deploy": "yarn workspace frontend ng build && yarn workspace backend deploy"
},
"packageManager": "yarn#3.1.0",
"dependencies": {
"#aws-sdk/client-ec2": "^3.34.0",
"#aws-sdk/client-elastic-load-balancing-v2": "^3.34.0",
"#middy/http-content-negotiation": "^2.5.1",
"esbuild": "^0.12.28"
}
}
frontend/package.json
{
"name": "frontend",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test"
},
"private": true,
"dependencies": {
"#angular/animations": "~12.2.0",
"#angular/cdk": "12.2.6",
"#angular/common": "~12.2.0",
"#angular/compiler": "~12.2.0",
"#angular/core": "~12.2.0",
"#angular/forms": "~12.2.0",
"#angular/material": "~12.2.6",
"#angular/platform-browser": "~12.2.0",
"#angular/platform-browser-dynamic": "~12.2.0",
"#angular/router": "~12.2.0",
"#aws-sdk/client-sns": "^3.34.0",
"#okta/okta-angular": "^4.1.0",
"#okta/okta-auth-js": "^5.6.0",
"rxjs": "~6.6.0",
"tslib": "^2.3.0",
"zone.js": "~0.11.4"
},
"devDependencies": {
"#angular-devkit/build-angular": "~12.2.5",
"#angular/cli": "~12.2.5",
"#angular/compiler-cli": "~12.2.0",
"#angular/localize": "^12.2.5",
"#types/jasmine": "~3.8.0",
"#types/node": "^12.11.1",
"jasmine-core": "~3.8.0",
"karma": "~6.3.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.0.3",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "~1.7.0",
"typescript": "~4.3.5"
}
}
backend/package.json
{
"name": "backend",
"scripts": {
"build": "tsc",
"watch": "tsc -w",
"test": "jest",
"cdk": "cdk",
"deploy": "yarn build && yarn cdk deploy"
},
"devDependencies": {
"#aws-cdk/assert": "^1.121.0",
"#aws-cdk/aws-apigateway": "1.121.0",
"#aws-cdk/aws-apigatewayv2": "1.121.0",
"#aws-cdk/aws-apigatewayv2-integrations": "1.121.0",
"#aws-cdk/aws-certificatemanager": "1.121.0",
"#aws-cdk/aws-dynamodb": "1.121.0",
"#aws-cdk/aws-ecs": "^1.121.0",
"#aws-cdk/aws-ecs-patterns": "^1.121.0",
"#aws-cdk/aws-lambda": "1.121.0",
"#aws-cdk/aws-lambda-event-sources": "1.121.0",
"#aws-cdk/aws-lambda-nodejs": "1.121.0",
"#aws-cdk/aws-logs": "1.121.0",
"#aws-cdk/aws-s3-deployment": "1.121.0",
"#aws-cdk/aws-sqs": "^1.121.0",
"#aws-solutions-constructs/aws-cloudfront-s3": "1.121.0",
"#types/aws-lambda": "^8.10.83",
"#types/http-errors": "^1.8.1",
"#types/jest": "^27.0.1",
"#types/node": "^16.9.6",
"#types/source-map-support": "^0.5.4",
"aws-cdk": "^1.121.0",
"eslint": "^7.32.0",
"jest": "^27.2.0",
"json-schema-to-ts": "^1.6.4",
"ts-jest": "^27.0.5",
"ts-node": "^10.2.1",
"typescript": "^4.4.3"
},
"dependencies": {
"#aws-cdk/aws-apigatewayv2-authorizers": "^1.130.0",
"#aws-cdk/cloud-assembly-schema": "^1.121.0",
"#aws-cdk/core": "^1.121.0",
"#aws-cdk/cx-api": "^1.121.0",
"#aws-cdk/region-info": "^1.121.0",
"#aws-sdk/client-dynamodb": "^3.34.0",
"#aws-sdk/client-ecs": "^3.34.0",
"#aws-sdk/client-elastic-load-balancing-v2": "^3.34.0",
"#aws-sdk/client-route-53": "^3.34.0",
"#aws-sdk/client-s3": "^3.34.0",
"#aws-sdk/client-sqs": "^3.34.0",
"#aws-sdk/lib-dynamodb": "^3.34.0",
"#aws-sdk/signature-v4-crt": "^3.34.0",
"#dazn/lambda-powertools-logger": "^1.28.1",
"#dazn/lambda-powertools-pattern-basic": "^1.29.0",
"#middy/core": "^2.5.1",
"#middy/http-cors": "^2.5.1",
"#middy/http-error-handler": "^2.5.1",
"#middy/http-json-body-parser": "^2.5.1",
"#middy/http-multipart-body-parser": "^2.5.1",
"#middy/sqs-json-body-parser": "^2.5.1",
"#middy/validator": "^2.5.1",
"#okta/jwt-verifier": "^2.3.0",
"ajv": "^8.6.3",
"aws-lambda": "^1.0.6",
"constructs": "^3.2.0",
"exponential-backoff": "^3.1.0",
"http-errors": "^1.8.0",
"middy-jsonapi": "2.0.1",
"source-map-support": "^0.5.16"
}
}
The problem turned out to have been my angular.json; in particular anywhere referring to ./node_modules/#angular. When I changed that to ../node_modules/#angular I was able to successfully build both frontend and backend.

Node.js / Angular unable to serve files behind symbolic links

We have an angular application that is deployed in a container, with an injected configuration file when starting (so not when building). We used to have it on Angular 7 (Node.js 10), and there we had no issues. We are currently in the process of upgrading to Angular 12 (Node.js 14), and are running into issues with our injected configuration file.
The configuration file is injected as assets/environments/environment.json, but in practice (due to the container system), environment.json is a symbolic link to assets/environments/.data/environment.json.
Now somewhere in the application, we try to get this file (through a regular HTTP call) to load our configuration. This http call works for http://<url>/assets/css/all.css, for example, but not for http://<url>/assets/environments/environment.json, seemingly because of the symbolic link.
What can we do to be able to HTTP get this file, hidden behind the symbolic link?
For completeness, our package.json:
{
"scripts": {
"start": "serve -s dist",
"build": "ng build --configuration production",
"serve": "ng serve --host 0.0.0.0",
"test": "ng test",
"lint": "ng lint"
},
"private": true,
"dependencies": {
"#angular/animations": "^12.1.0",
"#angular/cdk": "^12.1.0",
"#angular/cli": "^12.1.0",
"#angular/common": "^12.1.0",
"#angular/compiler": "^12.1.0",
"#angular/compiler-cli": "^12.1.0",
"#angular/core": "^12.1.0",
"#angular/forms": "^12.1.0",
"#angular/platform-browser": "^12.1.0",
"#angular/platform-browser-dynamic": "^12.1.0",
"#angular/router": "^12.1.0",
"#ngx-translate/core": "^13.0.0",
"#ngx-translate/http-loader": "^6.0.0",
"#popperjs/core": "^2.9.2",
"adal-angular": "^1.0.18",
"bootstrap": "^5.0.2",
"core-js": "^3.15.1",
"jquery": "^3.6.0",
"messageformat": "^2.3.0",
"ngx-translate-messageformat-compiler": "^4.10.0",
"popper.js": "^1.16.1",
"primeicons": "^4.1.0",
"primeng": "^12.0.0",
"process": "^0.11.10",
"rxjs": "^7.1.0",
"serve": "^12.0.0",
"tslib": "^2.3.0",
"util": "^0.12.4",
"zone.js": "^0.11.4"
},
"devDependencies": {
"#angular-builders/custom-webpack": "^12.1.0",
"#angular-devkit/build-angular": "^12.1.0",
"#angular/language-service": "^12.1.0",
"#types/adal-angular": "^1.0.1",
"#types/jasmine": "^3.7.7",
"#types/jasminewd2": "^2.0.9",
"#types/node": "^15.12.5",
"codelyzer": "^6.0.2",
"jasmine-core": "^3.7.1",
"jasmine-spec-reporter": "^7.0.0",
"karma": "^6.3.4",
"karma-chrome-launcher": "^3.1.0",
"karma-coverage-istanbul-reporter": "^3.0.3",
"karma-jasmine": "^4.0.1",
"karma-jasmine-html-reporter": "^1.6.0",
"protractor": "^7.0.0",
"ts-node": "^10.0.0",
"tslint": "^5.11.0",
"typescript": "^4.3.4"
}
}
and our angular.json:
{
"$schema": "./node_modules/#angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"application-name": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"prefix": "app",
"schematics": {},
"architect": {
"build": {
"builder": "#angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/",
"index": "src/index.html",
"main": "src/main.ts",
"preserveSymlinks": true,
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.app.json",
"assets": [
"./src/favicon.ico",
"./src/assets"
],
"styles": [
"./node_modules/bootstrap/dist/css/bootstrap.min.css",
"./src/assets/css/all.css",
"./src/styles.css"
],
"scripts": [
"./node_modules/bootstrap/dist/js/bootstrap.bundle.min.js",
"./node_modules/jquery/dist/jquery.slim.min.js",
"./node_modules/popper.js/dist/umd/popper.min.js"
]
},
"configurations": {
"production": {
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
}
]
}
}
},
"serve": {
"builder": "#angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "application-name:build"
},
"configurations": {
"production": {
"browserTarget": "application-name:build:production"
}
}
}
}
}
}
}

Error Not Yet Implemented with Webpack when run node dist/server.js

I were following the guide to implement Angular Universal for my application. Everything worked out well until the last command node dist/server.js throw an error Error: NotYetImplemented
The full traceback is here:
bash
Error: NotYetImplemented
at HTMLCanvasElement.exports.nyi (C:\Users\dist\server.js:50200:9)
at C:\Users\dist\server.js:238837:55
at Object.<anonymous> (C:\Users\dist\server.js:228511:20)
at svgNS (C:\Users\dist\server.js:228512:12)
at Object.defineProperty.value (C:\Users\dist\server.js:228520:2)
at __webpack_require__ (C:\Users\dist\server.js:20:30)
at Object.<anonymous> (C:\Users\dist\server.js:228463:14)
at __webpack_require__ (C:\Users\dist\server.js:20:30)
at Object.<anonymous> (C:\Users\dist\server.js:228427:89)
at __webpack_require__ (C:\Users\dist\server.js:20:30)
The current version of the packages in my application can be viewed here in package.json:
json
{
"name": "application",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build:ssr": "npm run build:client-and-server-bundles && npm run webpack:server",
"serve:ssr": "node dist/server.js",
"build:client-and-server-bundles": "ng build --production && ng build --production --app 1 --output-hashing=false",
"webpack:server": "webpack --config webpack.server.config.js --progress --colors",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"pre-commit": [
"ng lint -fix"
],
"dependencies": {
"#angular-devkit/core": "0.3.1",
"#angular/animations": "5.2.4",
"#angular/cli": "1.6.8",
"#angular/common": "5.2.4",
"#angular/compiler": "5.2.4",
"#angular/core": "5.2.4",
"#angular/forms": "5.2.4",
"#angular/http": "5.2.4",
"#angular/platform-browser": "5.2.4",
"#angular/platform-browser-dynamic": "5.2.4",
"#angular/platform-server": "5.2.4",
"#angular/router": "5.2.4",
"#ngui/auto-complete": "0.14.4",
"#nicky-lenaers/ngx-scroll-to": "0.3.1",
"#types/flickity": "2.0.0",
"angular-spinners": "5.0.2",
"angular2-drag-scroll": "1.5.2",
"bodymovin": "4.13.0",
"bootstrap-sass": "3.3.7",
"chart.js": "2.7.1",
"core-js": "2.5.3",
"express": "4.16.2",
"flickity": "2.0.10",
"font-awesome": "4.7.0",
"jquery": "3.2.1",
"ng-lottie": "0.3.1",
"ng-recaptcha": "3.0.3",
"ng-selectize": "1.1.3",
"ng2-charts": "1.6.0",
"ng2-device-detector": "1.0.1",
"ng2-input-autocomplete": "0.0.11",
"ngx-bootstrap": "2.0.2",
"ngx-cookie": "2.0.1",
"ngx-loading": "1.0.14",
"node-sass": "4.7.2",
"roboto-fontface": "0.8.0",
"rxjs": "5.5.6",
"selectize": "0.12.4",
"slick-carousel": "1.8.1",
"typescript": "^2.7.1",
"zone.js": "0.8.20"
},
"devDependencies": {
"#angular/compiler-cli": "5.2.4",
"#angular/language-service": "4.4.6",
"#types/jasmine": "2.8.6",
"#types/jasminewd2": "2.0.3",
"#types/node": "8.9.3",
"bootstrap-loader": "2.2.0",
"chalk": "2.3.1",
"codelyzer": "3.2.2",
"copy-webpack-plugin": "4.4.1",
"cssnano": "4.0.0-rc.2",
"domino": "2.0.0",
"enhanced-resolve": "4.0.0-beta.4",
"extract-text-webpack-plugin": "3.0.2",
"graceful-fs": "4.1.11",
"jasmine-core": "2.99.1",
"jasmine-spec-reporter": "4.2.1",
"jsdom": "11.6.2",
"karma": "1.7.1",
"karma-chrome-launcher": "2.2.0",
"karma-cli": "1.0.1",
"karma-coverage-istanbul-reporter": "1.4.1",
"karma-firefox-launcher": "1.1.0",
"karma-jasmine": "1.1.1",
"karma-jasmine-html-reporter": "0.2.2",
"lottie-web": "5.1.7",
"memory-fs": "0.4.1",
"npm-run-all": "4.1.2",
"protractor": "5.3.0",
"sass-lint": "1.12.1",
"tapable": "1.0.0-beta.5",
"ts-loader": "3.5.0",
"ts-node": "3.3.0",
"tslint": "5.9.1",
"uglify-js": "3.3.10",
"webpack": "3.11.0",
"webpack-dev-server": "2.11.1",
"webpack-merge": "3.0.0",
"webpack-node-externals": "1.6.0"
}
}
webpack.server.config.js
var path = require('path');
var webpack = require('webpack');
module.exports = {
entry: {
server: './src/server.ts'
},
resolve: {
extensions: ['.js', '.ts']
},
target: 'node',
// this makes sure we include node_modules and other 3rd party libraries
externals: [/(node_modules|main\..*\.js)/],
output: {
path: path.join(__dirname, 'dist'),
filename: '[name].js'
},
module: {
rules: [{
test: /\.ts$/,
loader: 'ts-loader'
}]
},
plugins: [
// Temporary Fix for issue: https://github.com/angular/angular/issues/11580
// for 'WARNING Critical dependency: the request of a dependency is an expression'
new webpack.ContextReplacementPlugin(
/(.+)?angular(\\|\/)core(.+)?/,
path.join(__dirname, 'src'), // location of your src
{} // a map of your routes
),
new webpack.ContextReplacementPlugin(
/(.+)?express(\\|\/)(.+)?/,
path.join(__dirname, 'src'), {}
)
]
};
Anyone saw the same problem can give me some insights? Many thanks!

Resources