I try to add Material Design to my project following the official tutorial ( https://material.angular.io/guide/getting-started ) but I get an error:
node_modules/#angular/cdk/typings/rxjs/rx-operators.d.ts(11,10): error TS2305: Module '"path_to_project/nod
e_modules/rxjs/Scheduler"' has no exported member 'IScheduler'.
node_modules/#angular/platform-browser/animations/src/providers.d.ts(8,119): error TS2305: Module '"path_to_project/node_modules/#angular/animations/browser"' has no exported member 'ɵDomAnimationEngine'.
I cannot find solution in the forums.
My package.json:
{
"name": "angular-quickstart",
"version": "1.0.0",
"description": "QuickStart package.json from the documentation, supplemented with testing support",
"scripts": {
"build": "tsc -p src/",
"build:watch": "tsc -p src/ -w",
"build:e2e": "tsc -p e2e/",
"serve": "lite-server -c=bs-config.json",
"serve:e2e": "lite-server -c=bs-config.e2e.json",
"prestart": "npm run build",
"start": "concurrently \"npm run build:watch\" \"npm run serve\"",
"pree2e": "npm run build:e2e",
"e2e": "concurrently \"npm run serve:e2e\" \"npm run protractor\" --kill-others --success first",
"preprotractor": "webdriver-manager update",
"protractor": "protractor protractor.config.js",
"pretest": "npm run build",
"test": "concurrently \"npm run build:watch\" \"karma start karma.conf.js\"",
"pretest:once": "npm run build",
"test:once": "karma start karma.conf.js --single-run",
"lint": "tslint ./src/**/*.ts -t verbose"
},
"keywords": [],
"author": "",
"license": "MIT",
"dependencies": {
"#angular/animations": "^4.2.6",
"#angular/cdk": "github:angular/cdk-builds",
"#angular/common": "~4.0.0",
"#angular/compiler": "~4.0.0",
"#angular/core": "~4.0.0",
"#angular/forms": "~4.0.0",
"#angular/http": "~4.0.0",
"#angular/material": "github:angular/material2-builds",
"#angular/platform-browser": "~4.0.0",
"#angular/platform-browser-dynamic": "~4.0.0",
"#angular/router": "~4.0.0",
"angular-in-memory-web-api": "~0.3.0",
"core-js": "^2.4.1",
"hammerjs": "^2.0.8",
"rxjs": "5.0.1",
"systemjs": "0.19.40",
"zone.js": "^0.8.4"
},
"devDependencies": {
"#types/jasmine": "2.5.36",
"#types/node": "^6.0.81",
"canonical-path": "0.0.2",
"concurrently": "^3.5.0",
"jasmine-core": "~2.4.1",
"karma": "^1.3.0",
"karma-chrome-launcher": "^2.2.0",
"karma-cli": "^1.0.1",
"karma-jasmine": "^1.0.2",
"karma-jasmine-html-reporter": "^0.2.2",
"lite-server": "^2.2.2",
"lodash": "^4.16.4",
"protractor": "~4.0.14",
"rimraf": "^2.5.4",
"tslint": "^3.15.1",
"typescript": "~2.2.2"
},
"repository": {}
}
and my systemjs.config.js:
/**
* System configuration for Angular samples
* Adjust as necessary for your application needs.
*/
(function (global) {
System.config({
paths: {
// paths serve as alias
'npm:': 'node_modules/'
},
// map tells the System loader where to look for things
map: {
// our app is within the app folder
'app': 'app',
// angular bundles
'#angular/core': 'npm:#angular/core/bundles/core.umd.js',
'#angular/common': 'npm:#angular/common/bundles/common.umd.js',
'#angular/compiler': 'npm:#angular/compiler/bundles/compiler.umd.js',
'#angular/platform-browser': 'npm:#angular/platform-browser/bundles/platform-browser.umd.js',
'#angular/platform-browser-dynamic': 'npm:#angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
'#angular/http': 'npm:#angular/http/bundles/http.umd.js',
'#angular/router': 'npm:#angular/router/bundles/router.umd.js',
'#angular/forms': 'npm:#angular/forms/bundles/forms.umd.js',
// other libraries
'rxjs': 'npm:rxjs',
'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js',
'#angular/material': 'npm:#angular/material/bundles/material.umd.js',
'#angular/cdk': 'npm:#angular/cdk/bundles/cdk.umd.js'
},
// packages tells the System loader how to load when no filename and/or no extension
packages: {
app: {
defaultExtension: 'js',
meta: {
'./*.js': {
loader: 'systemjs-angular-loader.js'
}
}
},
rxjs: {
defaultExtension: 'js'
}
}
});
})(this);
Newest material-2.0.0-beta.8 has a dependency on #angular/cdk which has a dependency on rxjs version 5.0.3 or greater.
So you have to change the rxjs version in your package.json:
npm install rxjs#5.0.3 --save
or
"rxjs": "~5.0.3"
Also, #angular/animations version 4.2.x has a know issue of
error TS2305: Module '"path_to_project/node_modules/#angular/animations/browser"' has no exported member 'ɵDomAnimationEngine'.
If you still get this error, you might need to fall back to version 4.1.x.
npm install '#angular/animations"#4.1.3' --save
Related
Been struggling for a couple days to run the project in prod and it just keeps showing different errors. The last one(hopefully) is:
> rimraf dist && tsc -p tsconfig.build.json
tsc-watch/test/fixtures/failing.ts(2,1): error TS1005: '}' expected.
But tsconfig.build.json is fine:
{
"extends": "./tsconfig.json",
"exclude": ["node_modules", "dist", "test", "**/*spec.ts"]
}
It happens after I try to build/run the docker container with:
docker-compose up --force-recreate --build
Here's what I have in the Dockerfile:
FROM node:11-stretch
ADD ./* $HOME/
RUN npm install
RUN npm run build
CMD npm run start:prod
And the package.json
{
"name": "mvp-api",
"private": true,
"version": "0.0.1",
"description": "MVP API",
"license": "MIT",
"scripts": {
"build": "rimraf dist && tsc -p tsconfig.build.json",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start": "ts-node -r tsconfig-paths/register src/main.ts",
"start:dev": "tsc-watch -p tsconfig.build.json --onSuccess \"node dist/main.js\"",
"start:debug": "tsc-watch -p tsconfig.build.json --onSuccess \"node --inspect-brk dist/main.js\"",
"start:prod": "node dist/main.js",
"lint": "tslint -p tsconfig.json -c tslint.json",
"test": "jest",
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json"
},
"dependencies": {
"#nestjs/common": "^6.5.3",
"#nestjs/core": "^6.5.3",
"#nestjs/jwt": "^6.1.1",
"#nestjs/microservices": "^6.0.4",
"#nestjs/passport": "^6.1.0",
"#nestjs/platform-express": "^6.0.4",
"#nestjs/swagger": "^3.1.0",
"#nestjs/typeorm": "^6.1.3",
"#nestjs/websockets": "^6.0.4",
"#nestrx/twilio": "0.0.2",
"#types/mailgun-js": "^0.22.3",
"#types/qrcode": "^1.3.4",
"aws-sdk": "^2.513.0",
"cache-manager": "^2.10.0",
"cache-manager-mongodb": "^0.2.1",
"cache-manager-redis-store": "^1.5.0",
"class-transformer": "^0.2.3",
"class-validator": "^0.10.0",
"dotenv": "^8.0.0",
"hbs": "^4.0.4",
"is-base64": "^0.1.0",
"libphonenumber-js": "^1.7.22",
"mailgun-js": "^0.22.0",
"mysql": "^2.17.1",
"nestjs-config": "^1.4.3",
"onesignal-node": "^2.1.1",
"passport": "^0.4.0",
"passport-jwt": "^4.0.0",
"qrcode": "^1.4.1",
"randomstring": "^1.1.5",
"reflect-metadata": "0.1.13",
"rimraf": "2.6.3",
"rxjs": "6.4.0",
"swagger-ui-express": "^4.0.7",
"twilio": "^3.33.4",
"typeorm": "^0.2.18",
"vcard-generator": "0.0.7"
},
"devDependencies": {
"#nestjs/testing": "6.1.1",
"#types/cache-manager": "^2.10.0",
"#types/express": "4.16.1",
"#types/jest": "24.0.11",
"#types/node": "11.13.4",
"#types/randomstring": "^1.1.6",
"#types/supertest": "2.0.7",
"jest": "24.7.1",
"prettier": "1.17.0",
"supertest": "4.0.2",
"ts-jest": "24.0.2",
"ts-loader": "^6.0.4",
"ts-node": "8.1.0",
"tsc-watch": "2.2.1",
"tsconfig-paths": "3.8.0",
"tslint": "5.16.0",
"typescript": "3.4.3",
"webpack": "^4.39.2",
"webpack-cli": "^3.3.6",
"webpack-node-externals": "^1.7.2"
},
"jest": {
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"rootDir": "src",
"testRegex": ".spec.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
},
"collectCoverageFrom": [
"**/*.(t|j)s"
],
"coverageDirectory": "../coverage",
"testEnvironment": "node"
}
}
It used to build fine with these configurations but after purging all containers/images and trying to recreate everything it just doesn't work.
Does anyone know how to get it to run properly in prod?
Apparently the problem was that the node_modules would keep copying over.
Adding a .dockerignore file with the following content solves the problem:
node_modules
Now I can run the docker container successfully.
When pushing my angular/node app to heroku it seems to build successfully when I look at the logs. But I can see no dist folder being created in the angular side.
I built the angular client locally to make sure there were no errors in the code.
I have changed the build script from -
"postinstall": "ng build --prod"
which was throwing "path to environment.prod.ts could not be found" error to
"heroku-postbuild": "ng build --configuration=production"
which doest throw errors but doesn't continue to create the dist folder. So I am stuck right a bit.
angular package.json
{
"name": "client",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "node app.js",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"heroku-postbuild": "ng build --configuration=production"
},
"private": true,
"dependencies": {
"#angular/cli": "~7.3.1",
"#angular/compiler-cli": "~7.2.0",
"typescript": "~3.2.2",
"#angular/animations": "^7.2.8",
"#angular/cdk": "^7.3.3",
"#angular/common": "~7.2.0",
"#angular/compiler": "~7.2.0",
"#angular/core": "~7.2.0",
"#angular/flex-layout": "^7.0.0-beta.24",
"#angular/forms": "~7.2.0",
"#angular/material": "^7.3.3",
"#angular/platform-browser": "~7.2.0",
"#angular/platform-browser-dynamic": "~7.2.0",
"#angular/router": "~7.2.0",
"#vguleaev/angular-material-autocomplete": "0.0.10",
"#w11k/ngx-componentdestroyed": "^4.1.4",
"core-js": "^2.5.4",
"rxjs": "~6.3.3",
"rxjs-observable-store": "^1.0.1",
"tslib": "^1.9.0",
"zone.js": "~0.8.26"
},
"devDependencies": {
"#angular-devkit/build-angular": "^0.13.9",
"#angular/language-service": "~7.2.0",
"#types/jasmine": "~2.8.8",
"#types/jasminewd2": "~2.0.3",
"#types/node": "~8.9.4",
"codelyzer": "~4.5.0",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~3.1.1",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.11.0"
},
"engines": {
"node": "10.0.0",
"npm": "5.6.0"
}
}
node package.json
{
"name": "spotify-alias",
"version": "1.0.0",
"description": "",
"main": "app.js",
"engines": {
"node": "10.0.0",
"npm": "5.6.0"
},
"dependencies": {
"#babel/cli": "^7.5.5",
"#babel/core": "^7.5.5",
"#babel/node": "^7.5.0",
"#babel/preset-env": "^7.5.0",
"axios": "^0.19.0",
"concurrently": "^4.1.0",
"cookie-session": "^1.3.3",
"cors": "^2.8.5",
"express": "^4.16.4",
"mongoose": "^5.4.14",
"node-fetch": "^2.3.0",
"passport": "^0.4.0",
"passport-spotify": "^1.0.1"
},
"devDependencies": {
"nodemon": "^1.19.1"
},
"scripts": {
"start": "node app.js",
"server": "nodemon --exec babel-node app.js",
"client": "npm start --prefix client",
"dev": "concurrently \"npm run server\" \"npm run client\"",
"heroku-postbuild": "NPM_CONFIG_PRODUCTION=false && npm install --prefix client"
},
"author": "",
"license": "ISC"
}
app.js - node
if(process.env.NODE_ENV === 'production') {
app.use(express.static('/client/dist/index.html'));
const path = require('path');
app.get('*', (req, res) => {
res.sendFile(path.resolve(__dirname, "client", "dist", "index.html"));
});
}
I would like everything to build and the dist folder to be created. This is my first node app so please bear with me, there might be things that look completely off.
Like I am not 100% sure about the app.js code that resolves the path. I do know that /client is where the angular stuff is from root.
Any help much appreciated.
You do not have a build script. I see that you're using Babel. Thus, you need to tell Babel to run a build for you; which ultimately provides the dist folder (could be any name though).
"build": "babel src --out-dir dist --copy-files",
Do follow the blog to deploy angular apps on heroku
https://medium.com/#hellotunmbi/how-to-deploy-angular-application-to-heroku-1d56e09c5147
I have followed the tutorial for nestJs and have a basic working app. After that, I tried the tutorial to connect my app with webpack and hotreloading and am now presented with the following error:
import { Entity, Column, PrimaryGeneratedColumn } from 'typeorm';
SyntaxError: Unexpected token {
at Module._compile (internal/modules/cjs/loader.js:703:23)
I have tried looking at similar errors and cannot find anything conclusive other than hints here and there to something that is not compiling in my test files - any direction would be greatly appreciated.
Using Node 12, npm 6.9.0
Package JSON below:
"scripts": {
"build": "tsc -p tsconfig.build.json",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start": "node dist/server",
"webpack": "webpack --config webpack.config.js",
"start:dev": "concurrently --handle-input \"wait-on dist/main.js && nodemon\" \"tsc -w -p tsconfig.build.json\" ",
"start:debug": "nodemon --config nodemon-debug.json",
"prestart:prod": "rimraf dist && npm run build",
"start:prod": "node dist/main.js",
"lint": "tslint -p tsconfig.json -c tslint.json",
"test": "jest",
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json"
},
"dependencies": {
"#nestjs/common": "^6.0.4",
"#nestjs/core": "^6.0.4",
"#nestjs/microservices": "^6.0.4",
"#nestjs/platform-express": "^6.0.4",
"#nestjs/swagger": "^3.0.2",
"#nestjs/typeorm": "^6.1.1",
"#nestjs/websockets": "^6.0.4",
"mysql": "^2.17.1",
"reflect-metadata": "0.1.13",
"rimraf": "2.6.3",
"rxjs": "6.4.0",
"swagger-ui-express": "^4.0.4",
"typeorm": "^0.2.17"
},
"devDependencies": {
"#nestjs/testing": "6.1.1",
"#types/express": "^4.16.1",
"#types/jest": "24.0.11",
"#types/node": "11.13.4",
"#types/supertest": "2.0.7",
"concurrently": "^4.1.0",
"jest": "24.7.1",
"nodemon": "1.18.11",
"prettier": "1.17.0",
"supertest": "4.0.2",
"ts-jest": "24.0.2",
"ts-loader": "^6.0.1",
"ts-node": "8.1.0",
"tsconfig-paths": "3.8.0",
"tslint": "5.16.0",
"typescript": "3.4.3",
"wait-on": "^3.2.0",
"webpack": "^4.32.2",
"webpack-cli": "^3.3.2",
"webpack-node-externals": "^1.7.2"
},
"jest": {
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"rootDir": "src",
"testRegex": ".spec.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
},
"collectCoverageFrom": [
"**/*.(t|j)s"
],
"coverageDirectory": "../coverage",
"testEnvironment": "node"
}
this is probably the tsconfig, are you using:
"module": "commonjs" In the compilerOptions ? When you working with nodejs this is the option that you have to use
I finally posted this on NestJS repo and received a response for those interested:
https://github.com/nestjs/nest/issues/2389
json:
{
"name": "angular-quickstart",
"version": "1.0.0",
"description": "QuickStart package.json from the documentation, supplemented with testing support",
"scripts": {
"build": "tsc -p src/",
"build:watch": "tsc -p src/ -w",
"build:e2e": "tsc -p e2e/",
"serve": "lite-server -c=bs-config.json",
"serve:e2e": "lite-server -c=bs-config.e2e.json",
"prestart": "npm run build",
"start": "concurrently \"npm run build:watch\" \"npm run serve\"",
"pree2e": "npm run build:e2e",
"e2e": "concurrently \"npm run serve:e2e\" \"npm run protractor\" --kill-others --success first",
"preprotractor": "webdriver-manager update",
"protractor": "protractor protractor.config.js",
"pretest": "npm run build",
"test": "concurrently \"npm run build:watch\" \"karma start karma.conf.js\"",
"pretest:once": "npm run build",
"test:once": "karma start karma.conf.js --single-run",
"lint": "tslint ./src/**/*.ts -t verbose"
},
"keywords": [],
"author": "",
"license": "MIT",
"dependencies": {
"#angular/common": "~4.0.0",
"#angular/compiler": "~4.0.0",
"#angular/core": "~4.0.0",
"#angular/forms": "~4.0.0",
"#angular/http": "~4.0.0",
"#angular/platform-browser": "~4.0.0",
"#angular/platform-browser-dynamic": "~4.0.0",
"#angular/router": "~4.0.0",
"#webcomponents/custom-elements": "^1.0.0-alpha.3",
"angular-in-memory-web-api": "~0.3.0",
"clarity-angular": "^0.8.12",
"clarity-icons": "^0.8.12",
"clarity-ui": "^0.8.12",
"core-js": "^2.4.1",
"rxjs": "5.0.1",
"systemjs": "0.19.40",
"zone.js": "^0.8.4"
},
"devDependencies": {
"concurrently": "^3.2.0",
"lite-server": "^2.2.2",
"typescript": "~2.1.0",
"canonical-path": "0.0.2",
"tslint": "^3.15.1",
"lodash": "^4.16.4",
"jasmine-core": "~2.4.1",
"karma": "^1.3.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-jasmine": "^1.0.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~4.0.14",
"rimraf": "^2.5.4",
"#types/node": "^6.0.46",
"#types/jasmine": "2.5.36"
},
"repository": {}
}
I was integrating clarity package with my angular 2 app. I have folloowed each steps and installed the clasrity-angular with npm install clarity-angular --save command, which is the last step. My app.module.ts
import { NgModule } from '#angular/core';
import { BrowserModule } from '#angular/platform-browser';
import { ClarityModule } from 'clarity-angular';
import { AppComponent } from './app.component';
#NgModule({
imports: [
BrowserModule,
ClarityModule.forRoot(),
],
declarations: [ AppComponent ],
bootstrap: [ AppComponent ]
})
export class AppModule { }
But whenever I add the line ClarityModule.forRoot(), am getting an error saying,
Failed to load resource: the server responded with a status of 404 (Not Found)
Any idea guys? Thanks in advance
As you are using Systemjs you should configure systemjs config properly:
System.config({
...
map: {
...
'clarity-angular': 'node_modules/clarity-angular/clarity-angular.umd.js',
},
...
});
I am facing a issue deploying angular2 app on azure. I get an error on following line
"engines":{"node":"6.2.1"},
I have given this version as WEBSITE_NODE_DEFAULT_VERSION has the value 6.2.1. Anyone having idea about this then please share.
Here is the error snapshot:
package.json looks as follows:
{
"name": "angular-quickstart",
"version": "1.0.0",
"engines":{"node":"6.2.1"},
"description": "QuickStart package.json from the documentation, supplemented with testing support",
"scripts": {
"start": "tsc && concurrently \"tsc -w\" \"lite-server\" ",
"docker-build": "docker build -t ng2-quickstart .",
"docker": "npm run docker-build && docker run -it --rm -p 3000:3000 -p 3001:3001 ng2-quickstart",
"pree2e": "npm run webdriver:update",
"e2e": "tsc && concurrently \"http-server -s\" \"protractor protractor.config.js\" --kill-others --success first",
"lint": "tslint ./app/*/.ts -t verbose",
"lite": "node_modules\.bin\lite-server",
"postinstall": "typings install",
"test": "tsc && concurrently \"tsc -w\" \"karma start karma.conf.js\"",
"test-once": "tsc && karma start karma.conf.js --single-run",
"tsc": "node_modules\.bin\tsc",
"concurrently": "node_modules\.bin\concurrently",
"tsc:w": "node_modules\.bin\tsc -w",
"typings": "node_modules\.bin\typings",
"webdriver:update": "webdriver-manager update"
},
"keywords": [],
"author": "",
"licenses": [
{
"type": "MIT",
"url": "https://github.com/angular/angular.io/blob/master/LICENSE"
}
],
"dependencies": {
"#angular/common": "~2.1.0",
"#angular/compiler": "~2.1.0",
"#angular/core": "~2.1.0",
"#angular/forms": "~2.1.0",
"#angular/http": "~2.1.0",
"#angular/platform-browser": "~2.1.0",
"#angular/platform-browser-dynamic": "~2.1.0",
"#angular/router": "~3.1.0",
"#angular/upgrade": "~2.1.0",
"angular-in-memory-web-api": "~0.1.5",
"bootstrap": "^3.3.7",
"systemjs": "0.19.39",
"core-js": "^2.4.1",
"reflect-metadata": "^0.1.8",
"rxjs": "5.0.0-beta.12",
"zone.js": "^0.6.25",
"concurrently": "^3.0.0",
"lite-server": "^2.2.2",
"typescript": "^2.0.3",
"typings": "^1.4.0"
},
"devDependencies": {
"concurrently": "^3.0.0",
"lite-server": "^2.2.2",
"typescript": "^2.0.3",
"typings": "^1.4.0",
"canonical-path": "0.0.2",
"http-server": "^0.9.0",
"tslint": "^3.15.1",
"lodash": "^4.16.2",
"jasmine-core": "~2.5.2",
"karma": "^1.3.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-htmlfile-reporter": "^0.3.4",
"karma-jasmine": "^1.0.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "^3.3.0",
"rimraf": "^2.5.4"
},
"repository": {}
}
Please suggest a solution.
When you deploy your app in a server or a cloud, you should run it on a port provided with process.env.PORT, here is an example:
app.listen(process.env.PORT || 3000, () => {
console.log('Example app is running!');
});
in your package.json file the start script is setting the app to run on port 3000 by default.
From Angular js2 Documentary:
If Node.js and npm aren't already on your machine, install them. Our examples require node v4.x.x or higher and npm 3.x.x or higher. To check which version you are using, run node -v and npm -v in a terminal window.
Could you please check your npm version?