-
Notifications
You must be signed in to change notification settings - Fork 12k
ng generate error #10653
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I have met the same issue. |
@nginx17 @WillsXiao , try to restart the terminal, issue caused by new thread. |
@TedCorleone I've tried it. It didn't work |
I have the same issue on OSX. |
@TedCorleone same as @WillsXiao didn't work |
same here on OSX, not only generates in the project root folder, but with all the path down to my project root folder. My project: When i generate, for example, home module: |
Just generated a new angular 6 project and tried to generate a module or a component and had the same issue, i`m using the latest version:
|
Same here |
the generated file should be put in the default project. For now, you must specify the project name with --project projectName |
@sandangel still doesn't work |
@nginx17 notice that your project must be placed in the projectRoot folder configued in angular.json ng g c home --project example
CREATE projects/example/src/app/home/home.component.css (0 bytes)
CREATE projects/example/src/app/home/home.component.html (23 bytes)
CREATE projects/example/src/app/home/home.component.spec.ts (614 bytes)
CREATE projects/example/src/app/home/home.component.ts (257 bytes)
UPDATE projects/example/src/app/app.module.ts (442 bytes) |
@sandangel i try what i missed, angular.json default generated, not change |
@sandangel, still not working It says there is no ngModule because its looking in the wrong place, what OS are you using? |
@matheusdavidson i think this is not about OS, you used OSX and i used Linux, but problem is same. i don't know how about windows |
I am also having this problem. |
Samesies. Having the problem as well. With brand new project generation -- default angular.json. |
hi everyone, try this: ng new newproj
ng g app example #generate another app
ng g c home --project example #generate component in example app I guess your global ng cli was not updated to v6 or ng v6 does not recognize project not placed in "projects" folder. ng new newproj
CREATE newproj/README.md (1024 bytes)
CREATE newproj/angular.json (3408 bytes)
CREATE newproj/package.json (1311 bytes)
CREATE newproj/tsconfig.json (384 bytes)
CREATE newproj/tslint.json (2805 bytes)
CREATE newproj/.editorconfig (245 bytes)
CREATE newproj/.gitignore (503 bytes)
CREATE newproj/src/environments/environment.prod.ts (51 bytes)
CREATE newproj/src/environments/environment.ts (631 bytes)
CREATE newproj/src/favicon.ico (5430 bytes)
CREATE newproj/src/index.html (294 bytes)
CREATE newproj/src/main.ts (370 bytes)
CREATE newproj/src/polyfills.ts (3194 bytes)
CREATE newproj/src/test.ts (642 bytes)
CREATE newproj/src/assets/.gitkeep (0 bytes)
CREATE newproj/src/styles.css (80 bytes)
CREATE newproj/src/browserslist (375 bytes)
CREATE newproj/src/karma.conf.js (964 bytes)
CREATE newproj/src/tsconfig.app.json (194 bytes)
CREATE newproj/src/tsconfig.spec.json (282 bytes)
CREATE newproj/src/tslint.json (314 bytes)
CREATE newproj/src/app/app.module.ts (314 bytes)
CREATE newproj/src/app/app.component.css (0 bytes)
CREATE newproj/src/app/app.component.html (1141 bytes)
CREATE newproj/src/app/app.component.spec.ts (986 bytes)
CREATE newproj/src/app/app.component.ts (207 bytes)
CREATE newproj/e2e/protractor.conf.js (752 bytes)
CREATE newproj/e2e/src/app.e2e-spec.ts (299 bytes)
CREATE newproj/e2e/src/app.po.ts (208 bytes)
CREATE newproj/e2e/tsconfig.e2e.json (213 bytes)
> fsevents@1.2.3 install /Users/sand/Downloads/newproj/node_modules/fsevents
> node install
[fsevents] Success: "/Users/sand/Downloads/newproj/node_modules/fsevents/lib/binding/Release/node-v57-darwin-x64/fse.node" already installed
Pass --update-binary to reinstall or --build-from-source to recompile
> node-sass@4.9.0 install /Users/sand/Downloads/newproj/node_modules/node-sass
> node scripts/install.js
Cached binary found at /Users/sand/.npm/node-sass/4.9.0/darwin-x64-57_binding.node
> node-sass@4.9.0 postinstall /Users/sand/Downloads/newproj/node_modules/node-sass
> node scripts/build.js
Binary found at /Users/sand/Downloads/newproj/node_modules/node-sass/vendor/darwin-x64-57/binding.node
Testing binary
Binary is fine
> @angular/cli@6.0.0 postinstall /Users/sand/Downloads/newproj/node_modules/@angular/cli
> node ./bin/ng-update-message.js
added 1146 packages from 1269 contributors in 20.672s
Successfully initialized git.
##################################################################################
ng g c home --project newproj
CREATE src/app/home/home.component.css (0 bytes)
CREATE src/app/home/home.component.html (23 bytes)
CREATE src/app/home/home.component.spec.ts (614 bytes)
CREATE src/app/home/home.component.ts (261 bytes)
UPDATE src/app/app.module.ts (388 bytes)
|
@sandangel what do you mean by "ng v6 does not recognize project not placed in "projects" folder"? are you in a projects directory in your example? I assume all commands are run from the same directory level in your example |
@johren01 I mean with a newly created project, cli will generate app files under "src" folder, but if we generate a new app, by |
you are correct, I have correctly fixed my issue following your directions. thank you!
… On May 6, 2018, at 6:31 PM, San Nguyen ***@***.***> wrote:
@johren01 <https://github.com/johren01> I mean with a newly created project, cli will generate it under "src" folder, but if we generate a new app, by ng g app, generated files will be placed under "projects" folder. So I think when using ng g c home --project projName, if the projName is not placed under "projects" folder, the generated path might be wrong. I have tried but mine works fine for both project under "src" folder and "projects" folder. So I think may be your global cli version was not upgraded to 6. That what I guess based on your provided information. I can't reproduce your issue now on my macOS machine
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#10653 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/ARtB_VmdanzzhnuL1FWMVSgd2EylZE_Aks5tv3m5gaJpZM4TzTZc>.
|
Haha my issue was much more of a noob mistake. Upgraded my ng cli globally, but did not exit terminal for it to refresh (my guess) because now it seems to work just fine. :) |
I've solved my issued on my computer. My problems are below:
Solve the problem
The angular results are below:
Here is my angular info
|
@WillsXiao, It shoudn’t be so difficult do generate things, that may be a workaround, not a solution. |
@sandangel Problem solved, my case is same as @WillsXiao |
It looks like this was released in devkit 6.0.8 (CLI 6.0.8) but I'm still having the same problem:
and the angular.json which hasn't changed since upgrading to 6.0.0:
|
Still broken; though maybe broken in a different way. It seems to be ignoring the 'defaultProject' setting, and instead yanking the last project out of the list of projects. If I reorder my angular.json file such that the -e2e project is first, and the standard project is second, then generation of a new component goes into the correct location, instead of attempting to drop into -e2e. |
@darinclark Nailed it! I just tested by reordering my angular.json projects listing to put the e2e project first and the main project 2nd and then everything started working. I found this already reported: #11111 |
After upgrading cli to 6.0.8, cli is generating everything inside e2e folder. |
@rfuhrer That worked for me!! Thanks. Just pasting it here for others. Very simple fix for now. It appears to just grab the last project in your angular.json. So if you have a main project and then a e2e project, reorder them so the main project is last and your default generate commands will go to the main project instead of e2e. If you need to generate something to the e2e project then you can use the --path e2e override |
You can use "ng new you_project_name" copy angular.json paste to your original project directory. |
this is still happening on 6.0.8. This also still happened to me after moving the non e2e project after the others. And this happened to me because I ran 'ng update' on my project. found the answer here: basically, find the 'project name'-e2e |
Worked by moving the e2e project in angular.json to top of the project list |
That didn't work for me, hence more digging and now works without moving projects in angular.json. |
Thanks @dkteam 👏 |
For me worked that I changed the path. I was in src folder. |
@grimace works fine :) |
@grimace was very helpful, thanks |
Very much like @grimace 's workaround above. For me, I was able to leave the project order the same in {
"projects": {
"myGreatApp": {
"root": ""
},
"myGreatApp-e2e": {
"root": "e2e"
}
}
}
Angular 6.0.6 |
Deleting the "e2e" in angular.json under: to "app-e2e": { fixed my problem! |
Same problem on Windows, after upgrading to the latest cli (6.1.1). The solution that worked for me was suggested by @srkt
|
I'm not having any problem changing the root folder from ng new ng-test --style scss --skip-install Save the patch file diff --git a/angular.json b/angular.json
index 56f7e2e..2d30500 100644
--- a/angular.json
+++ b/angular.json
@@ -5,7 +5,7 @@
"projects": {
"ng-test": {
"root": "",
- "sourceRoot": "src",
+ "sourceRoot": "client",
"projectType": "application",
"prefix": "app",
"schematics": {
@@ -18,16 +18,16 @@
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/ng-test",
- "index": "src/index.html",
- "main": "src/main.ts",
- "polyfills": "src/polyfills.ts",
- "tsConfig": "src/tsconfig.app.json",
+ "index": "client/index.html",
+ "main": "client/main.ts",
+ "polyfills": "client/polyfills.ts",
+ "tsConfig": "client/tsconfig.app.json",
"assets": [
- "src/favicon.ico",
- "src/assets"
+ "client/favicon.ico",
+ "client/assets"
],
"styles": [
- "src/styles.scss"
+ "client/styles.scss"
],
"scripts": []
},
@@ -35,8 +35,8 @@
"production": {
"fileReplacements": [
{
- "replace": "src/environments/environment.ts",
- "with": "src/environments/environment.prod.ts"
+ "replace": "client/environments/environment.ts",
+ "with": "client/environments/environment.prod.ts"
}
],
"optimization": true,
@@ -71,17 +71,17 @@
"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",
+ "main": "client/test.ts",
+ "polyfills": "client/polyfills.ts",
+ "tsConfig": "client/tsconfig.spec.json",
+ "karmaConfig": "client/karma.conf.js",
"styles": [
- "src/styles.scss"
+ "client/styles.scss"
],
"scripts": [],
"assets": [
- "src/favicon.ico",
- "src/assets"
+ "client/favicon.ico",
+ "client/assets"
]
}
},
@@ -89,8 +89,8 @@
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
- "src/tsconfig.app.json",
- "src/tsconfig.spec.json"
+ "client/tsconfig.app.json",
+ "client/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
@@ -128,4 +128,4 @@
}
},
"defaultProject": "ng-test"
-}
\ No newline at end of file
+}
diff --git a/client/tsconfig.app.json b/client/tsconfig.app.json
index 8ea061e..7e02a41 100644
--- a/client/tsconfig.app.json
+++ b/client/tsconfig.app.json
@@ -5,7 +5,7 @@
"types": []
},
"exclude": [
- "src/test.ts",
+ "client/test.ts",
"**/*.spec.ts"
]
} Apply the patch file and install vendor: git apply root-change.diff
npm i All the following commands works: ng serve --open
ng build --prod
ng test
ng e2e Component generation will correctly generate the component in the new root folder: ng g c home --dry-run
CREATE client/app/home/home.component.html (23 bytes)
CREATE client/app/home/home.component.spec.ts (614 bytes)
CREATE client/app/home/home.component.ts (262 bytes)
CREATE client/app/home/home.component.scss (0 bytes)
UPDATE client/app/app.module.ts (388 bytes)
$ ng g m core --dry-run
CREATE client/app/core/core.module.spec.ts (259 bytes)
CREATE client/app/core/core.module.ts (188 bytes) |
My fix was fairly simple: Problem: I was running the command Solution: Back out into the root of your angular project and specify the path you want the component to generate in like so:
The above command should create a "home" component in the Hope that helps! |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Versions
Angular CLI: 6.0.0
Node: 8.9.1
OS: linux x64
Angular: 6.0.0
... animations, cdk, cli, common, compiler, compiler-cli, core
... forms, http, language-service, material, platform-browser
... platform-browser-dynamic, platform-server, router
Package Version
angular-devkit/architect 0.6.0
angular-devkit/build-angular 0.6.0
angular-devkit/build-optimizer 0.6.0
angular-devkit/core 0.6.0
angular-devkit/schematics 0.6.0
ngtools/webpack 6.0.0
schematics/angular 0.6.0
schematics/update 0.6.0
rxjs 6.1.0
typescript 2.7.2
webpack 4.6.0
Repro steps
ng g component home
ng g component home --skip-import (same as generate everything)
The text was updated successfully, but these errors were encountered: