ng g c cname --flat gives directory error
Please provide us with the following information:
-
OS? MacOS Sierra
-
Versions. angular-cli: 1.0.0-beta.14 node: 6.6.0 os: darwin x64
-
Repro steps. App created with cli ng g c name_of_component cd to the component directory ng g c name_of_sub_component --flat -it -is
-
The log given by the failure. installing component Error locating module for declaration Error: ENOENT: no such file or directory, scandir '/Users/nathan/Sites/A2Cl/first-app/src/app/Volumes/Macintosh HD/other' Directory is incorrect It adds /Volumes/Macintosh HD/ in the middle of a perfectly good path.
-
Mention any other details that might be useful. I am comfortable in Angular new to Angular 2. Going through an online course and hit this error.
Thanks! We'll be in touch soon.
Just verified that on my system this is repeatable.
- ng new first-app2
- cd first-app2
- ng g c other
- cd src/app/other/
- ng g c another --flat -it -is
installing component Error locating module for declaration Error: ENOENT: no such file or directory, scandir '/Users/nathan/Sites/A2Cl/first-app2/src/app/Volumes/Macintosh HD/other'
I have verified that I can use ng g c from the root of the project but any other directory will give this error even without the --flat flag.
I think this has since been fixed, this is the result I'm getting in the latest versions:
kamik@T460p MINGW64 /D/sandbox/master-proj (master)
$ ng g c other
installing component
create src\app\other\other.component.css
create src\app\other\other.component.html
create src\app\other\other.component.spec.ts
create src\app\other\other.component.ts
kamik@T460p MINGW64 /D/sandbox/master-proj (master)
$ cd src/app/other/
kamik@T460p MINGW64 /D/sandbox/master-proj/src/app/other (master)
$ ng g c another --flat -it -is
installing component
create src\app\another.component.spec.ts
create src\app\another.component.ts
Yup, works for me now too.
Still broken.
The location of your app.module.ts is fundamental to the success of 'ng g c my-component' command.
I'd moved mine into a subfolder 'src\app\shared', along with the other app.* files and this resulted in the error 'Error locating module for declaration'
Moving app.module.ts back to the 'src\app' folder fixed the issue and the command succeeded either from the '\src' folder or the '\src\app' folder.
I was also able to successfully issue the command from wherever app.module.ts lived, e.g. '\src\app\shared'
@sophistyx what you seem to be describing isn't the original issue here. Please open a new issue.
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.