angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

angular-cli generated directory structure not working when a different src dir is used

Open vegeta03 opened this issue 9 years ago • 9 comments

Bug Report or Feature Request (mark with an x)

- [x ] bug report
- [ ] feature request

Versions.

Angular CLI: 1.5.0 Node: 7.7.2 OS: win32 x64 Angular: 5.0.1 ... animations, common, compiler, compiler-cli, core, forms ... http, language-service, platform-browser ... platform-browser-dynamic, router

@angular/cli: 1.5.0 @ angular-devkit/build-optimizer: 0.0.32 @ angular-devkit/core: 0.0.20 @ angular-devkit/schematics: 0.0.35 @ ngtools/json-schema: 1.1.0 @ ngtools/webpack: 1.8.0 @ schematics/angular: 0.1.2 typescript: 2.4.2 webpack: 3.8.1

Windows 7

Repro steps.

ng new testNg -sd=src/main/webapp/ ng serve

The log given by the failure.

D:\Shyam\Workspace\testNg>ng serve ENOENT: no such file or directory, stat 'D:\Shyam\Workspace\testNg\src\main\webapp\tsconfig.app.json' Error: ENOENT: no such file or directory, stat 'D:\Shyam\Workspace\testNg\src\main\webapp\tsconfig.app.json' at Object.fs.statSync (fs.js:967:11) at AngularCompilerPlugin._setupOptions (D:\Shyam\Workspace\testNg\node_modules@ngtools\webpack\src\angular_compiler_plugin.js:78:16) at new AngularCompilerPlugin (D:\Shyam\Workspace\testNg\node_modules@ngtools\webpack\src\angular_compiler_plugin.js:43:14) at _createAotPlugin (D:\Shyam\Workspace\testNg\node_modules@angular\cli\models\webpack-configs\typescript.js:77:16) at Object.getNonAotConfig (D:\Shyam\Workspace\testNg\node_modules@angular\cli\models\webpack-configs\typescript.js:100:19) at NgCliWebpackConfig.buildConfig (D:\Shyam\Workspace\testNg\node_modules@angular\cli\models\webpack-config.js:33:37) at Class.run (D:\Shyam\Workspace\testNg\node_modules@angular\cli\tasks\serve.js:71:98) at check_port_1.checkPort.then.port (D:\Shyam\Workspace\testNg\node_modules@angular\cli\commands\serve.js:123:26) at process._tickCallback (internal/process/next_tick.js:109:7)

Desired functionality.

ng serve should run the without errors.

Mention any other details that might be useful.

Only the app module is generated within the specified source-directory (ng new testNg -sd=src/main/webapp/) , other files such as tsconfig** files and others are generated within default src directory. The generated .angular-cli.json settings are not helping with these changes.

log when generating the app: D:\Shyam\Workspace>ng new testNg -sd=src/main/webapp/ create testNg/e2e/app.e2e-spec.ts (289 bytes) create testNg/e2e/app.po.ts (208 bytes) create testNg/e2e/tsconfig.e2e.json (235 bytes) create testNg/karma.conf.js (923 bytes) create testNg/package.json (1312 bytes) create testNg/protractor.conf.js (722 bytes) create testNg/README.md (1022 bytes) create testNg/tsconfig.json (363 bytes) create testNg/tslint.json (2985 bytes) create testNg/.angular-cli.json (1281 bytes) create testNg/.editorconfig (245 bytes) create testNg/.gitignore (516 bytes) create testNg/src/assets/.gitkeep (0 bytes) create testNg/src/environments/environment.prod.ts (51 bytes) create testNg/src/environments/environment.ts (387 bytes) create testNg/src/favicon.ico (5430 bytes) create testNg/src/index.html (293 bytes) create testNg/src/main.ts (370 bytes) create testNg/src/polyfills.ts (2667 bytes) create testNg/src/styles.css (80 bytes) create testNg/src/test.ts (1085 bytes) create testNg/src/tsconfig.app.json (211 bytes) create testNg/src/tsconfig.spec.json (304 bytes) create testNg/src/typings.d.ts (104 bytes) create testNg/src/main/webapp/app/app.module.ts (316 bytes) create testNg/src/main/webapp/app/app.component.html (1120 bytes) create testNg/src/main/webapp/app/app.component.spec.ts (986 bytes) create testNg/src/main/webapp/app/app.component.ts (207 bytes) create testNg/src/main/webapp/app/app.component.css (0 bytes) Installing packages for tooling via yarn. Installed packages for tooling via yarn. Successfully initialized git. Project 'testNg' successfully created.

The .angular-cli.json contents: { "$schema": "./node_modules/@angular/cli/lib/config/schema.json", "project": { "name": "test-ng" }, "apps": [ { "root": "src/main/webapp/", "outDir": "dist", "assets": [ "assets", "favicon.ico" ], "index": "index.html", "main": "main.ts", "polyfills": "polyfills.ts", "test": "test.ts", "tsconfig": "tsconfig.app.json", "testTsconfig": "tsconfig.spec.json", "prefix": "app", "styles": [ "styles.css" ], "scripts": [], "environmentSource": "environments/environment.ts", "environments": { "dev": "environments/environment.ts", "prod": "environments/environment.prod.ts" } } ], "e2e": { "protractor": { "config": "./protractor.conf.js" } }, "lint": [ { "project": "src/main/webapp//tsconfig.app.json", "exclude": "/node_modules/" }, { "project": "src/main/webapp//tsconfig.spec.json", "exclude": "/node_modules/" }, { "project": "e2e/tsconfig.e2e.json", "exclude": "/node_modules/" } ], "test": { "karma": { "config": "./karma.conf.js" } }, "defaults": { "styleExt": "css", "component": {} } }

vegeta03 avatar Nov 09 '17 09:11 vegeta03

using angular-cli v1.2.8 different source-dir is working fine.

vegeta03 avatar Nov 10 '17 11:11 vegeta03

Thanks for posting this question. I also have the same issue. Do you mean, degrade angular-cli to 1.2.8? I have similar project structure but I like to keep all my app config in src/main/webapp. Meaning, project-root/src/main/webapp/app project-root/src/main/webapp/assets project-root/src/main/webapp/environments project-root/src/main/webapp/indexhtml .... .... And my angular-cli config is beside my src directory under project-root like below project-root/src project-root/.angular-cli.json project-root/.editorconfig ..... ..... Do you have any idea how to achieve this? thanks

tirumala123 avatar Nov 10 '17 11:11 tirumala123

@tirumala123 I used npm install -g @angular/[email protected] for the src dir to work.

I cant use angular-cli 1.5 to generate angular5 app with custom src dir it produces error

vegeta03 avatar Nov 10 '17 16:11 vegeta03

I not sure, is my question have relative to this issue or not. Please give me advice I want generate app into this file structure:

/f/main - for css, js
/index.html - entry point

and save option delete output path only for /f/main and save all files into / (for example robots.txt) Is possible configure cli for this task?

For more clarify — I can move files by this file structure without hashing in chunks, but all lazyload modules will try loading from / but not from /f/main as I want.

Dok11 avatar Nov 10 '17 17:11 Dok11

@Dok11 i don't think this issue is related to your question.

vegeta03 avatar Nov 10 '17 18:11 vegeta03

Hi @Brocco , Currently i am using cli v1.2.8 for custom source-dir which gives Angular 4 app. I am using ngrx4 ( this requires RxJS 5 ) in the app. Will this issue be resolved soon, should i wait, so that i can use Angular 5 with custom source-dir and ngrx 4 without dependency issues.

Thank you Shyam

vegeta03 avatar Nov 21 '17 07:11 vegeta03

The fix does not work for me properly if I want to add a component to a feature module (Angular CLI 1.6.0).

ng g c atoms/icon
create src/client/app/atoms/icon/icon.component.html (23 bytes)
create src/client/app/atoms/icon/icon.component.spec.ts (614 bytes)
create src/client/app/atoms/icon/icon.component.ts (261 bytes)
create src/client/app/atoms/icon/icon.component.scss (0 bytes)

The atoms folder contains a atoms.module.ts which won't be updated. The root property in angular-cli.json is set to src/client. app.module.ts would be updated:

ng g c icon -d
create src/client/app/icon/icon.component.html (23 bytes)
create src/client/app/icon/icon.component.spec.ts (614 bytes)
create src/client/app/icon/icon.component.ts (261 bytes)
create src/client/app/icon/icon.component.scss (0 bytes)
update src/client/app/app.module.ts (1504 bytes)

esagawe avatar Dec 08 '17 18:12 esagawe

This doesn't work for me either. Using Angular CLI "@angular/cli": "~7.3.6",

basickarl avatar Aug 13 '19 13:08 basickarl

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.