Skip to content

ng g module my-module only generates the module.ts file #6844

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

Closed
vlrprbttst opened this issue Jun 29, 2017 · 10 comments
Closed

ng g module my-module only generates the module.ts file #6844

vlrprbttst opened this issue Jun 29, 2017 · 10 comments

Comments

@vlrprbttst
Copy link

i'm just starting with angular and i was following a beginner screencast tutorial.
when the guy creates a new module: https://youtu.be/fXHyqSIIF9Q?t=14m10s angular-cli spits css/html/component files as you can see, but on my local environment all i get is the xxx.module.ts file. and this warning:

WARNING Module is generated but not provided, it must be provided to be used

is there something wrong or is it an old screencast?

sorry for the very noob question. just moving my very first steps here

@rageshvr
Copy link

rageshvr commented Jun 29, 2017

As per issue #3365 and PR #3389 this has changed to have only module generated by default.

But with the --routing flag it should generate the component as per generate-module.spec.js

it('ng generate module  generate routing and component files when passed flag --routing', 
function () {}

and e2e/tests/generate/module/module-routing.ts

I have tried it and generate is not creating the component or the spec with --routing flag. I am not sure if I am missing something or if this is a regression. Doc's say nothing about the routing flag though.

Module not provided is just a warning. You can specify --module=, eg: --module=app to import the newly created module to an existing module to get rid of those warning.

@rageshvr
Copy link

Since new version is out:
I had verified this in version 1.1.3

@tytskyi
Copy link

tytskyi commented Jun 29, 2017

is it an old screencast?

video is from Oct 5, 2016

First stable release Mar 24 2017: https://github.com/angular/angular-cli/releases/tag/v1.0.0

Please refer to the docs: https://github.com/angular/angular-cli/wiki

@juristr
Copy link
Contributor

juristr commented Jun 30, 2017

is it an old screencast?

Yep it is :smiley. I'm the author of the screencast and I created it now nearly 10 months ago. While the shown Angular techniques are still valid, the CLI has changed its behavior in some cases such as in this one.

So while before it generated the module and some sample components as well, now you have to do it separately in two steps:

$ ng g module people

and then generate the component

$ ng g component people/people

which generates a people.component.ts in the module people, therefore the people/people.

Also take a look at the docs, they're quite good now:

Hope that helps, otherwise simply ping me again if you have any further questions 😉

@rageshvr
Copy link

Can confirm in 1.2.0, ng generate module --routing not creating component.

@angular/cli: 1.2.0
node: 8.1.3
os: win32 x64
@angular/animations: 4.2.5
@angular/common: 4.2.5
@angular/compiler: 4.2.5
@angular/core: 4.2.5
@angular/forms: 4.2.5
@angular/http: 4.2.5
@angular/platform-browser: 4.2.5
@angular/platform-browser-dynamic: 4.2.5
@angular/router: 4.2.5
@angular/cli: 1.2.0
@angular/compiler-cli: 4.2.5
@angular/language-service: 4.2.5
ng new my-app
cd my-app
ng g m my-module --routing
create src\app\my-module\my-module-routing.module.ts
  create src\app\my-module\my-module.module.ts
  WARNING Module is generated but not provided, it must be provided to be used

Can someone please confirm, if --routing flag can be used to create module along with component?

@juristr
Copy link
Contributor

juristr commented Jun 30, 2017

@rageshvr --routing is for creating routing information. See the docs

Just as a hint, you can also add --dry-run to just check which files would be created by the CLI without any effect on your file system.

@rageshvr
Copy link

Yeah my bad, I interpreted it wrong. It create only route with that flag.

@juristr
Copy link
Contributor

juristr commented Jul 2, 2017

@vlrprbttst I think this issue can be closed, right? //cc @rageshvr

@Ranjita-M
Copy link

Ranjita-M commented May 15, 2018

Hi there!!
Look at the default settings of module in schema.json(node_modules/@angular/cli/lib/config/schema.json) file. Change as required..

If module->properties->spec->default(find in below code) is false, it only generates module.ts. By default, it is false. If you want to generate module.spec.ts file, change it to true..

"module":
{
"description": "Options for generating a module.",
"type": "object",
"properties":
{
"flat":
{
"description": "Flag to indicate if a dir is created.",
"type": "boolean",
"default": false
},
"spec":
{
"description": "Specifies if a spec file is generated.",
"type": "boolean",
"default": false
}
}
}

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants