You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Angular cli Generates Wrong Directory Path in app.module.ts #7135
ERROR in /Users/u.name/myProject/src/app/app.module.ts (5,38): Cannot find module './common/src/app/common/my-component/my-component.component'.
ERROR in ./src/app/app.module.ts
Module not found: Error: Can't resolve './common/src/app/common/my-component/my-component.component' in '/Users/u.name/myPoject/src/app'
@ ./src/app/app.module.ts 10:0-99
@ ./src/main.ts
@ multi webpack-dev-server/client?http://localhost:4200 ./src/main.ts
Desired functionality.
The path written is constantly adding "src/app" part whereas older version of the cli did not have this behavior
The correct import statement should be : import { MyComponentComponent } from './common/my-component/my-component.component';
Not only in app.module.ts. i have nested modules that contains components which i generate using the command ng g c <component_name>. What happens is that it prepends the import path with ./src/app. It should be ./ or ./<current_working_directory>.
I confirm this issue, I was about to open a ticket.
More details about the problem :
ng new test
cd test
ng g component first
is OK, but :
cd src/app (or any other dir)
ng g component second
generates an invalid path (and thus a compile error) in AppModule : import { SecondComponent } from './src/app/second/second.component';
@filipesilva I suspect it's due to the new change of baseUrl in tsconfig.json in #6861 , even if reverting back to old config doesn't solve the problem.
A test is missing, a regression on such a basic command is not normal.
I am facing one more issue related to this. After updating to 1.2.4, the import statement of environment object is changed to import { environment } from 'environments/environment'; and i had make it relative again manually at every place.
There is currently 3 major problems with generation (this one, #6533 and #7061). Some of them dating from several weeks ago, and I'm quite worried to see new versions of the CLI released without any fix for these major regressions. I tried to help with a PR for one of them, posted one month ago, but which has been completely ignored.
Speed is nice, but a working tool should be a priority. Currently the generation has become so buggy I'm starting to think about stopping to use it during the trainings I do...
Activity
exequiel09 commentedon Jul 26, 2017
Not only in
app.module.ts. i have nested modules that contains components which i generate using the commandng g c <component_name>. What happens is that it prepends the import path with./src/app. It should be./or./<current_working_directory>.Versions.
@angular/cli: 1.2.4
node: 6.11.0
os: darwin x64
@angular/animations: 4.3.1
@angular/common: 4.3.1
@angular/compiler: 4.3.1
@angular/core: 4.3.1
@angular/forms: 4.3.1
@angular/http: 4.3.1
@angular/platform-browser: 4.3.1
@angular/platform-browser-dynamic: 4.3.1
@angular/router: 4.3.1
@angular/cli: 1.2.4
@angular/compiler-cli: 4.3.1
@angular/language-service: 4.3.1
fsx999 commentedon Jul 26, 2017
i have the same issue
Itisfilipe commentedon Jul 26, 2017
+1
hiepxanh commentedon Jul 27, 2017
me too
cyrilletuzi commentedon Jul 28, 2017
I confirm this issue, I was about to open a ticket.
More details about the problem :
is OK, but :
generates an invalid path (and thus a compile error) in
AppModule:import { SecondComponent } from './src/app/second/second.component';@filipesilva I suspect it's due to the new change of
baseUrlintsconfig.jsonin #6861 , even if reverting back to old config doesn't solve the problem.A test is missing, a regression on such a basic command is not normal.
filipesilva commentedon Jul 28, 2017
@Brocco can you have a look?
djtahl commentedon Jul 30, 2017
I've checked on an older angular-cli version and found one that didn't had the issue :
angular-cli 1.0.6 didn't had this generated path issue
deveshjadon98 commentedon Jul 31, 2017
@djtahl same case with me, it was working fine with 1.0.6 but after updating to 1.2.4 it's giving wrong relative path.
deveshjadon98 commentedon Jul 31, 2017
I am facing one more issue related to this. After updating to 1.2.4, the import statement of environment object is changed to
import { environment } from 'environments/environment';and i had make it relative again manually at every place.cyrilletuzi commentedon Aug 3, 2017
Any news about this ?
There is currently 3 major problems with generation (this one, #6533 and #7061). Some of them dating from several weeks ago, and I'm quite worried to see new versions of the CLI released without any fix for these major regressions. I tried to help with a PR for one of them, posted one month ago, but which has been completely ignored.
Speed is nice, but a working tool should be a priority. Currently the generation has become so buggy I'm starting to think about stopping to use it during the trainings I do...
17 remaining items
test: Add tests for running 'generate' in a subdirectory (#7135) (#7284)
hansl commentedon Aug 23, 2017
This issue was fixed in 1.4.0, but not 1.3. We are looking at fixing it in 1.3 as well.
fix(@angular/cli): fix import path for component when importing into …
test(@angular/cli): Add tests for running 'generate' in a subdirectory (
test(@angular/cli): Add more tests for running 'generate' in a subdir…
test: Add tests for running 'generate' in a subdirectory (angular#7135)…
andrewkww commentedon Aug 24, 2017
Great! Thanks @hansl !
test(@angular/cli): Add tests for running 'generate' in a subdirectory (
test(@angular/cli): Add more tests for running 'generate' in a subdir…
test: Add tests for running 'generate' in a subdirectory (#7135) (#7284)
nemeth-tibor commentedon Jan 11, 2018
I use 1.6.3 and ng new project-name still results:
Error: Path "/app/app.module.ts" does not exist.
Path "/app/app.module.ts" does not exist.
test: Add tests for running 'generate' in a subdirectory (angular#7135)…
angular-automatic-lock-bot commentedon Sep 7, 2019
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.