ng generate with lint fix results in "no such file or directory" error
See original GitHub issueBug Report or Feature Request (mark with an x
)
- [X] bug report -> please search issues before submitting
- [ ] feature request
Command (mark with an x
)
- [ ] new
- [ ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [X] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc
Versions
NodeJS: v8.10.0 npm: 6.4.1
Angular CLI: 6.2.4
Node: 8.10.0
OS: win32 x64
Angular: 6.1.9
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.8.4
@angular-devkit/build-angular 0.8.4
@angular-devkit/build-optimizer 0.8.4
@angular-devkit/build-webpack 0.8.4
@angular-devkit/core 0.8.4
@angular-devkit/schematics 0.8.4
@angular/cli 6.2.4
@ngtools/webpack 6.2.4
@schematics/angular 0.8.4
@schematics/update 0.8.4
rxjs 6.2.2
typescript 2.9.2
webpack 4.20.2
Repro steps
- Create a new project using
ng new
- Edit the
angular.json
-File and add a Schematics-Configuration with thelintFix
-Option:
"schematics": {
"@schematics/angular:component": {
"lintFix": true
}
},
This Code can be inserted right before the projects
-Node.
- Add a fixable tslint-rule, which collides with the default schematics. Examples are:
"linebreak-style": [
true,
"CRLF"
],
"quotemark": [
true,
"double"
],
- Create a component using
ng generate component
The log given by the failure
>ng g component test
CREATE src/app/test/test.component.html (23 bytes)
CREATE src/app/test/test.component.spec.ts (614 bytes)
CREATE src/app/test/test.component.ts (261 bytes)
CREATE src/app/test/test.component.css (0 bytes)
UPDATE src/app/app.module.ts (388 bytes)
ENOENT: no such file or directory, scandir 'C:\Users\User\Angular\project\src\app\src\app\test'
Note, that it looks for project\src\app\src\app\test
instead of project\src\app\test
Desired functionality
I would expect, that the lintFix
-Option fixes all lint errors in the newly generated component.ts
and component.spec.ts
files. However, those files still use “LF” instead of “CRLF” and they still have Single-quotes instead of Double-Quotes.
Mention any other details that might be useful
The lintFix
-Option disappeared in angular/cli@6.0 as mentioned in #11034 and came back with #11648.
It should be part of angular/cli@6.2.x and it is part of it’s schematics schema file
Issue Analytics
- State:
- Created 5 years ago
- Reactions:6
- Comments:14
Top Results From Across the Web
Can't run ng lint on my angular-cli project - Stack Overflow
To fix the linting problem, add following into the .angular-cli.json ... Please run following commands to make sure, that both have the same ......
Read more >ng test - Angular
Option Description Value Type Defau...
‑‑browsers Override which browsers tests are run against. string
‑‑code‑coverage Output a code coverage report. boolean false
‑‑code‑coverage‑exclude Globs to exclude...
Read more >TSLint command-line interface - Palantir Open Source
--fix: Fixes linting errors for select rules. This may overwrite linted files. --force: Return status code 0 even if there are any lint...
Read more >lint-staged - npm
prettierignore file. Running npx prettier . will ignore the entire vendor directory, throwing no errors. When lint-staged is added to the ...
Read more >Identify and Fix Build and Deployment Errors in Your Angular ...
Usually, this can easily be fixed by stopping the ng serve process and re-running it because this allows the Webpack development server running ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
After noticing, that the lint-fixing seems to work for a colleague of mine, in the exact same project, we investigated a bit more. Here is what we found out:
ng g service core/x --project app1
at the project root works and fixes all lint-errors.ng g service x
insideapps/app1/src/app/core
gives the mentioned error.So it seems like the lint-fix only works, if the commands are executed at root-level. Hope this helps.
Also having this problem.