angular-7-jwt-authentication-example icon indicating copy to clipboard operation
angular-7-jwt-authentication-example copied to clipboard

Unable to add new componet

Open dev01prishusoft opened this issue 5 years ago • 2 comments

Hi

When I tried to add a new component with the following syntax

ng g c component-name it give me error as below

You have to be inside an angular-cli project in order to use the generate command.

dev01prishusoft avatar Jan 11 '19 04:01 dev01prishusoft

This is because this repo don't use angular client (I wonder why...) Run npm i @angular/cli then create angular.json file at your project root with this content: (change you're project name, etc) { "$schema": "./node_modules/@angular/cli/lib/config/schema.json", "version": 1, "projects": { "project": { "root": "", "sourceRoot": "src", "projectType": "application", "prefix": "app", "schematics": { "@schematics/angular:component": { "styleext": "scss" } }, "architect": { "build": { "builder": "@angular-devkit/build-angular:browser", "options": { "outputPath": "dist/project", "index": "src/index.html", "main": "src/main.ts", "polyfills": "src/polyfills.ts", "tsConfig": "src/tsconfig.app.json", "assets": [ "src/favicon.ico", "src/assets" ], "styles": [ "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, "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": "project:build" }, "configurations": { "production": { "browserTarget": "project:build:production" } } }, "extract-i18n": { "builder": "@angular-devkit/build-angular:extract-i18n", "options": { "browserTarget": "project:build" } }, "test": { "builder": "@angular-devkit/build-angular:karma", "options": { "main": "src/test.ts", "polyfills": "src/polyfills.ts", "tsConfig": "src/tsconfig.spec.json", "karmaConfig": "src/karma.conf.js", "styles": [ "src/styles.scss" ], "scripts": [], "assets": [ "src/favicon.ico", "src/assets" ] } }, "lint": { "builder": "@angular-devkit/build-angular:tslint", "options": { "tsConfig": [ "src/tsconfig.app.json", "src/tsconfig.spec.json" ], "exclude": [ "**/node_modules/**" ] } } } }, "project-e2e": { "root": "e2e/", "projectType": "application", "prefix": "", "architect": { "e2e": { "builder": "@angular-devkit/build-angular:protractor", "options": { "protractorConfig": "e2e/protractor.conf.js", "devServerTarget": "project:serve" }, "configurations": { "production": { "devServerTarget": "project:serve:production" } } }, "lint": { "builder": "@angular-devkit/build-angular:tslint", "options": { "tsConfig": "e2e/tsconfig.e2e.json", "exclude": [ "**/node_modules/**" ] } } } } }, "defaultProject": "project" } Then run ng update Then run ng g c component-name, it will return an error like

Cannot find module '@angular/compiler-cli' Error: Cannot find module '@angular/compiler-cli'

Fix it with npm i @angular/compiler-cli (adapt with the error) and repeat untill it works.

PierreDemailly avatar Jan 29 '19 15:01 PierreDemailly

This project is available in both webpack and angular CLI flavor, for CLI version check this one out : https://github.com/cornflourblue/angular-7-registration-login-example-cli

mehars-jalin avatar May 25 '19 06:05 mehars-jalin