I am relatively new to angular 2. I want to use angular2-grid directory. What I have done is creating a folder for my application with all necessary starting file and then run npm-install. Installation is completed and the demo application is working after I typed npm start. Then I want to set up angular2-grid and in the official website is saying to use it you simply have to run npm install angular2-grid. I tried that but I got some warning like :
npm WARN angular2-grid#2.0.1 requires a peer of #angular/core#^2.4.4
but none was installed. npm WARN angular2-grid#2.0.1 requires a peer
of rxjs#^5.0.1 but none was installed. npm WARN angular2-grid#2.0.1
requires a peer of zone.js#^0.7.2 but none was installed.
I need some help how to overcome this problem. Any suggestion is welcome.
My package.json below:
{
"name": "product-management",
"version": "1.0.0",
"author": "Deborah Kurata",
"description": "Package for the Acme Product Management sample application",
"scripts": {
"start": "tsc && concurrently \"tsc -w\" \"lite-server\" ",
"tsc": "tsc",
"tsc:w": "tsc -w",
"lint": "tslint ./app/**/*.ts -t verbose",
"lite": "lite-server",
"typings": "typings",
"postinstall": "typings install"
},
"license": "ISC",
"dependencies": {
"#angular/common": "2.0.0",
"#angular/compiler": "2.0.0",
"#angular/core": "2.0.0",
"#angular/forms": "2.0.0",
"#angular/http": "2.0.0",
"#angular/platform-browser": "2.0.0",
"#angular/platform-browser-dynamic": "2.0.0",
"#angular/router": "3.0.0",
"core-js": "^2.4.1",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.12",
"systemjs": "0.19.27",
"zone.js": "^0.6.23",
"bootstrap": "^3.3.6"
},
"devDependencies": {
"concurrently": "^2.2.0",
"lite-server": "^2.2.0",
"tslint": "^3.7.4",
"typescript": "^2.0.2",
"typings": "^1.0.4"
},
"repository": {}
}
Thanks
your existing Angular version and RXJS version is lower than what angular-grid requires. Either go for an older version of angular-grid or update your project if possible
For your angular2-grid to be added as a dependency in package.json you need to do
npm install angular2-grid --save
{
"name": "product-management",
"version": "1.0.0",
"author": "Deborah Kurata",
"description": "Package for the Acme Product Management sample application",
"scripts": {
"start": "tsc && concurrently \"tsc -w\" \"lite-server\" ",
"tsc": "tsc",
"tsc:w": "tsc -w",
"lint": "tslint ./app/**/*.ts -t verbose",
"lite": "lite-server",
"typings": "typings",
"postinstall": "typings install"
},
"license": "ISC",
"dependencies": {
"#angular/common": "2.0.0",
"#angular/compiler": "2.0.0",
"#angular/core": "2.0.0",
"#angular/forms": "2.0.0",
"#angular/http": "2.0.0",
"#angular/platform-browser": "2.0.0",
"#angular/platform-browser-dynamic": "2.0.0",
"#angular/router": "3.0.0",
"core-js": "^2.4.1",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.12",
"systemjs": "0.19.27",
"zone.js": "^0.6.23",
"bootstrap": "^3.3.6"
},
"devDependencies": {
"concurrently": "^2.2.0",
"lite-server": "^2.2.0",
"tslint": "^3.7.4",
"typescript": "^2.0.2",
"typings": "^1.0.4"
},
"repository": {}
}
Related
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.
I've recently upgraded my angular2 app to angular 5 and I am having trouble deploying it to heroku where it used to work beforehand.
The issue here is that I have a Procfile that has this: 'web: node dist/server/app.js' - where the launch file is stored but heroku is trying to find it add this path - 'app/dist/server/app.js' I'm not sure where this /app is getting appended but it is causing the issue.
Cheers
error description
{
"name": "",
"version": "4.2.4",
"license": "",
"author": "",
"description": "",
"angular-cli": {},
"engines": {
"node": "8.9.4",
"npm": "5.6.0"
},
"scripts": {
"ng": "ng",
"build": "ng build --prod",
"start": "node dist/server/app.js",
"predev": "tsc -p server",
"dev": "node ./node_modules/mongodb-migrate -runmm -dbn dbSettings up && concurrently \"mongod\" \"ng serve -pc proxy.conf.json --open\" \"tsc -w -p server\" \"nodemon dist/server/app.js\"",
"prod": "concurrently \"mongod\" \"ng build -aot -prod && tsc -p server && node dist/server/app.js\"",
"test": "ng test",
"testbe": "tsc -p server && mocha dist/server/test --exit",
"lint": "ng lint",
"lintbe": "tslint server/**/**.ts{,x}",
"e2e": "ng e2e",
"migrations": "node ./node_modules/mongodb-migrate -runmm -dbn dbSettings up",
"create-migration": "node ./node_modules/mongodb-migrate -runmm create"
},
"private": true,
"dependencies": {
"#angular/animations": "^5.2.0",
"#angular/cdk": "2.0.0-beta.12",
"#angular/common": "^5.2.0",
"#angular/compiler": "^5.2.0",
"#angular/core": "^5.2.0",
"#angular/forms": "^5.2.0",
"#angular/http": "^5.2.0",
"#angular/material": "2.0.0-beta.12",
"#angular/platform-browser": "^5.2.0",
"#angular/platform-browser-dynamic": "^5.2.0",
"#angular/router": "^5.2.0",
"#sendgrid/mail": "^6.2.1",
"angular-bootstrap-md": "^5.1.2",
"angular2-jwt": "^0.2.3",
"bcryptjs": "^2.4.3",
"body-parser": "^1.18.2",
"bootstrap": "4.0.0-alpha.5",
"cheerio": "^1.0.0-rc.2",
"core-js": "^2.4.1",
"cron": "^1.3.0",
"dotenv": "^4.0.0",
"express": "^4.16.3",
"font-awesome": "^4.7.0",
"hammerjs": "^2.0.8",
"jquery": "^3.3.1",
"jsonwebtoken": "^8.2.1",
"migrate-mongo": "^2.2.1",
"moment": "^2.20.1",
"mongodb-migrate": "^2.0.2",
"mongoose": "^5.0.13",
"morgan": "^1.9.0",
"popper.js": "^1.14.3",
"npm-check": "^5.6.0",
"redis": "^2.8.0",
"request": "^2.85.0",
"rxjs": "^5.5.6",
"tether": "1.4.0",
"zone.js": "^0.8.19"
},
"devDependencies": {
"#angular/cli": "~1.7.3",
"#angular/compiler-cli": "^5.2.0",
"#angular/language-service": "^5.2.0",
"#types/jasmine": "^2.8.6",
"#types/jasminewd2": "~2.0.2",
"#types/node": "~6.0.60",
"chai": "^4.1.2",
"chai-http": "^4.0.0",
"codelyzer": "~4.0.1",
"concurrently": "^3.5.1",
"jasmine-core": "~2.8.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~2.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"mocha": "^5.0.5",
"nodemon": "^1.17.3",
"protractor": "~5.1.2",
"ts-node": "~4.1.0",
"tslint": "~5.9.1",
"typescript": "~2.5.3"
}
}
I once came across with a similar issue with a nodejs typescript application that I had connected with git. The .gitingnore file omits js files. So when heroku takes a pull from git it only obtains typescript script(no js files). Where as the npm start script refers to js files.
Another thing to note it that heroku runs only two commands
npm install
and
npm start
Solution
Add ng build into the start script so that production files are available for heroku.
package.json
"ng": "ng",
"build": "ng build --prod",
"start": "ng build --prod && node dist/server/app.js",
I've cloned a working Ionic project from github and installed all the modules needed, also using npm install #firebase/app, but when running Ionic serve an error page is shown saying Cannot find module 'firebase/app'. When I installed firebase/app, it showed me this in the shell:
I guess there's a problem with the angularfire2 version that causes me the other problem? Which version should I use and how can I downgrade/upgrade that? To install angularfire2 I've simply run npm install angularfire2.
This is my package.json file:
{
"name": "progettoEM",
"version": "0.0.1",
"author": "Ionic Framework",
"homepage": "http://ionicframework.com/",
"private": true,
"scripts": {
"clean": "ionic-app-scripts clean",
"build": "ionic-app-scripts build",
"lint": "ionic-app-scripts lint",
"ionic:build": "ionic-app-scripts build",
"ionic:serve": "ionic-app-scripts serve"
},
"dependencies": {
"#angular/common": "4.4.3",
"#angular/compiler": "4.4.3",
"#angular/compiler-cli": "4.4.3",
"#angular/core": "4.4.3",
"#angular/forms": "4.4.3",
"#angular/http": "4.4.3",
"#angular/platform-browser": "4.4.3",
"#angular/platform-browser-dynamic": "4.4.3",
"#firebase/app": "^0.1.5",
"#ionic-native/camera": "^4.5.2",
"#ionic-native/core": "4.3.0",
"#ionic-native/diagnostic": "^4.5.2",
"#ionic-native/file": "^4.5.2",
"#ionic-native/geolocation": "^4.5.2",
"#ionic-native/google-maps": "^4.5.2",
"#ionic-native/secure-storage": "^4.5.2",
"#ionic-native/splash-screen": "4.3.0",
"#ionic-native/status-bar": "4.3.0",
"#ionic/storage": "2.0.1",
"angularfire2": "^5.0.0-rc.4",
"graphhopper-js-api-client": "^0.9.0-3",
"ionic-angular": "3.7.1",
"ionic-img-viewer": "^2.9.0",
"ionicons": "3.0.0",
"leaflet": "^1.2.0",
"rxjs": "5.4.3",
"sw-toolbox": "3.6.0",
"zone.js": "0.8.18"
},
"devDependencies": {
"#ionic/app-scripts": "3.0.0",
"#ionic/cli-plugin-cordova": "1.6.2",
"#ionic/cli-plugin-ionic-angular": "1.4.1",
"ionic": "3.13.1",
"typescript": "2.3.4"
},
"description": "An Ionic project"
}
How do I resolve this problem?
Written one mocha test case with chai in Typescript and followed the article http://brianflove.com/2016/11/11/typescript-2-express-mongoose-mocha-chai/ to install all dependencies.
While I am running the test cases with "npm test", I am getting below error
C:\J\MEAN\MSDN-App\node_modules\#angular\core\bundles\core.umd.js:335
throw 'reflect-metadata shim is required when using class decorators';
^
reflect-metadata shim is required when using class decorators
npm ERR! Test failed. See above for more details.
The package.json is:
{
"name": "test-app",
"version": "1.0.0",
"description": "test description",
"main": "server.js",
"scripts": {
"start": "tsc && concurrently \"tsc -w\" \"lite-server\" ",
"test": "mocha -r ts-node/register test/**/*.ts",
"lite": "lite-server",
"postinstall": "typings install",
"tsc": "tsc",
"tsc:w": "tsc -w",
"typings": "typings"
},
"author": "",
"license": "ISC",
"dependencies": {
"#angular/common": "^2.0.1",
"#angular/compiler": "^2.0.1",
"#angular/core": "^2.0.1",
"#angular/forms": "^2.0.1",
"#angular/http": "^2.0.1",
"#angular/platform-browser": "^2.0.1",
"#angular/platform-browser-dynamic": "^2.0.1",
"#angular/router": "^3.4.10",
"#angular/upgrade": "^2.0.1",
"#covalent/core": "^1.0.0-beta.3-2",
"#ngrx/store": "^2.0.1",
"#types/node": "7.0.7",
"#types/underscore": "^1.8.0",
"angular-in-memory-web-api": "^0.1.1",
"body-parser": "^1.17.1",
"bootstrap": "^3.3.7",
"core-js": "^2.4.1",
"ejs": "^2.5.6",
"express": "^4.15.2",
"mongojs": "^2.4.0",
"node-sspi": "^0.1.14",
"nodemailer": "^4.0.1",
"nodemailer-smtp-transport": "^2.7.4",
"properties-reader": "0.0.15",
"reflect-metadata": "^0.1.10",
"rxjs": "5.0.0-beta.12",
"systemjs": "0.19.39",
"ts-node": "^3.0.4",
"underscore": "^1.8.3",
"zone.js": "^0.6.25"
},
"devDependencies": {
"#types/chai": "^3.5.2",
"#types/core-js": "0.9.35",
"#types/mocha": "^2.2.41",
"chai": "^3.5.0",
"concurrently": "^3.0.0",
"lite-server": "^2.2.2",
"mocha": "^3.4.1",
"reflect-metadata": "^0.1.10",
"ts-node": "^3.0.4",
"typescript": "^2.0.3",
"typings": "^1.4.0"
}
}
And tsconfig.json is:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false
},
"exclude": [
"node_modules",
"node_modules/#types",
"bower_components",
"typings"
]
}
Please help to resolve the error.
Very simple answer but hard to find out. Should not include the #angular/http in test.ts files and to test services use unit testing, to test angular components we must test with Angular testing utilities.
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?