-
Notifications
You must be signed in to change notification settings - Fork 12k
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
Cannot create components with CLI on Windows #7960
Comments
This situation also happens on ASP.NET Core + Angular4 projects generated by ASP.NET Core CLI, which was manually added a .angular-cli.json file not included in originally, when trying to add a component with "ng g c xxx ". |
Exactly the same bug here. I also tried to downgrade to 1.4.0 but it doesn't work don't know why (i'll try 1.3.2). Here my ng version (project created with ng new my-proj --source-dir=src/angular):
|
For now, the best solution for me is explicitly adding import module path: |
Still having this problem. Cannot generate any components on Windows. Incredibly annoying to deal with. |
@hansl , thank you so much for all of your hard work on this. You're much appreciated at my office! I'll give a little more details on my specific issue. I've been an OSX dev for years, but I'm forced to use Windows 10 for the next few months. I duplicated my environment as much as possible and this issue is definitely only happening in Windows. I tried some suggestions from other threads including upgrading to Node 8, downgrading to 1.4.2 CLI, and @YuxuanLin 's suggestion of explicitly naming the module path. None of them work. Here's the exact output I get: The command "generate" has an option without the required type and name fields. |
@YuxuanLin That won't work. If you create a sub-directory for all the angular code and specify the module through the cli command, it'll still create an odd hierarchy of folders like the one showed by Feeni |
I am creating a project to support multiple apps and ran into a similar (or perhaps same) scenario. For starters, I'm using @angular/cli@1.5.0-beta.4 (on Windows) since I needed appRoot support. The basic directory structure is similar to .NET Core features where all code is grouped by folders and client code lives right next to server code, which is why appRoot is called Client. I've pushed the common Angular config files to the root so they are shared across apps, so the structure is as follows (I've obviously left out some files from this listing):
More importantly, here are the associated CLI config values:
When I run the command with --skip-import and dry run, I get the following as others have been observing:
Without skip-import, it's also unable to track down the module to add it to as a result of the wrong path. I spent some time adding logging to the angular-cli code and came up with the following findings that I hope will help troubleshoot this:
commandOptions values
When seeing the behavior in find-module.js, it looks like the root problem there is in the way that it builds out the pathToCheck.
pathToCheck logic
resulting pathToCheck value I took a quick look in the component\index.js file that is used to create components and it has similar logic:
I'm not sure what the exact fix is since this code has to support multiple combinations of command option values, but hopefully this helps isolate the issue. Thanks. |
A temporary workaround is switching to bash on windows when using This should really be a highly prioritized bug to fix. |
I agree with @vilic |
If this could be fixed in the short term, that would be great. From what I mentioned earlier, the issue looks to be that the sourceDir and path values in the command options both base off of the root value from the CLI config. They are then concatenated together in all of the index.js files for items that can be generated, resulting in the doubled up path parts. If you need any more info, I'd be glad to provide it. |
#8559 should fix it, I believe. Thanks for the repros and investigation into it, it really helped debug the problem. |
I was using bash and it did not work. Is there any solution? I get permission denied error |
So Angular doesn't currently work on Windows? I'm working through the tutorial and I got stuck here:
|
I'm having the same problem. "Upgraded" to Angular 6, and now I can no longer generate components, services, etc. "Could not find an NgModule" |
@jeffreymichell facing same issue after upgrading to angular 6. Has anyone able to fix the issue ? |
use --skip-import flag to ignore this message because otherwise angular-cli will look for a module to declare the component and if it can't find it it won't generate component. try this and it should work.
|
I have the same problem after upgrading to Angular 6, same versions as the user above me. |
This issue should be resolved by #11143 as the default project is being determined incorrectly when the two apps have the same root defined. |
I had the same problem after upgrading a project from Angular 4.3 to Angular 6. The problem turned out to be the Please note that |
i was facing same issue. When I tried creating a new component, it got added into e2e folder. That gave me hint that somewhere root folder has changed. If you in angular.json and change root from e2e to src, you would be able to create components. |
@drullo thank you. thats what exactly i needed to do to fix the error. |
Thanks @drullo . It fixed my problem. |
@drullo Your solution worked for me perfectly. Thank you. |
I was using ionic and tried everything. But this is the only thing that worked.
where g can be generate and page can be component too. Notice the syntax of --module, because for me |
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. |
We are not able to generate components on a project that's using a slightly different directory structure. After a bit of testing, it seems like it's a Windows path issue as generating components on Macbooks are working just fine.
Bug Report or Feature Request (mark with an
x
)Versions.
Repro steps.
ng new PROJECT-NAME
apps
folder inside of thesrc
folder.src/app
intosrc/apps
, which will result in a file structure ofsrc/apps/app/<component>
.angular-cli.json
to besrc/apps
The final result of executing steps 1 to 4 can be seen here: https://github.com/Feeni/angular-cli-windows
ng g c test-me -d
- an error will appear statingCould not find an NgModule for the new component. Use the skip-import option to skip importing components in NgModule.
ng g c test-me --skip-import -d
- it will do a dry run of the component creation, but the path will besrc/apps/src/apps/<component>
. Notice how the root seems to be duplicated twice.The log given by the failure.
NOTE: While there are no errors above, note how the path of
src/apps
is being copied twice.Desired functionality.
We would like to use the Angular CLI to generate components even with a different directory structure on Windows.
Mention any other details that might be useful.
v.1.3.2
, as generating components in Windows works fine in that version.The text was updated successfully, but these errors were encountered: