question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Component not generated in specified directory.

See original GitHub issue

Please provide us with the following information:

  1. OS? Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?)

Windows 10

  1. Versions. Please run ng --version. If there’s nothing outputted, please run in a Terminal: node --version and paste the result here:

angular-cli: 1.0.0-beta.11-webpack.2 node: 5.10.1 os: win32 x64

  1. Repro steps. Was this an app that wasn’t created using the CLI? What change did you do on your code? etc.

change to a directory, for example, /app/components, then run ng g component new-component

  1. The log given by the failure. Normally this include a stack trace and some more information.

installing component create src\app\new-component\new-component.component.css create src\app\new-component\new-component.component.html create src\app\new-component\new-component.component.spec.ts create src\app\new-component\new-component.component.ts create src\app\new-component\index.ts create src\app\new-component\shared\index.ts

  1. Mention any other details that might be useful.

The documentation states:

“# if in the directory src/app/feature/ and you run” ng g component new-cmp “# your component will be generated in src/app/feature/new-cmp”

so the results should have been this:

installing component create src\app\components\new-component\new-component.component.css create src\app\components\new-component\new-component.component.html create src\app\components\new-component\new-component.component.spec.ts create src\app\components\new-component\new-component.component.ts create src\app\components\new-component\index.ts create src\app\components\new-component\shared\index.ts


Thanks! We’ll be in touch soon.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
Phatsuocommented, Sep 20, 2016

OK, #1633 is closed, and as of Beta 15, this is still an issue, even with a brand new project.

My angular-cli.json:

{
  "project": {
    "version": "1.0.0-beta.15",
    "name": "cli-test-beta15"
  },
  "apps": [
    {
      "root": "src",
      "outDir": "dist",
      "assets": "assets",
      "index": "index.html",
      "main": "main.ts",
      "test": "test.ts",
      "tsconfig": "tsconfig.json",
      "prefix": "app",
      "mobile": false,
      "styles": [
        "styles.css"
      ],
      "scripts": [],
      "environments": {
        "source": "environments/environment.ts",
        "dev": "environments/environment.ts",
        "prod": "environments/environment.prod.ts"
      }
    }
  ],
  "addons": [],
  "packages": [],
  "e2e": {
    "protractor": {
      "config": "./protractor.conf.js"
    }
  },
  "test": {
    "karma": {
      "config": "./karma.conf.js"
    }
  },
  "defaults": {
    "styleExt": "css",
    "prefixInterfaces": false
  }
}

I have discovered a workaround. The following commands do allow the creation of new entities in the directory of choice. Perhaps just the documentation is incorrect at this point.

$ ng g component components//my-new-component-9 installing component create src\app\components\my-new-component-9\my-new-component-9.component.css create src\app\components\my-new-component-9\my-new-component-9.component.html create src\app\components\my-new-component-9\my-new-component-9.component.spec.ts create src\app\components\my-new-component-9\my-new-component-9.component.ts

$ ng g service services//my-new-service-3 installing service create src\app\services\my-new-service-3.service.spec.ts create src\app\services\my-new-service-3.service.ts WARNING Service is generated but not provided, it must be provided to be used

The only slight problem being in app.module.ts the path ends up as (note the backslash after ‘components’):

import { MyNewComponent9Component } from './components\my-new-component-9/my-new-component-9.component';

and it has to be changed to:

import { MyNewComponent9Component } from './components/my-new-component-9/my-new-component-9.component';

1reaction
whiskeysauercommented, Jan 2, 2017

I am working through some tutorials and have discovered this as well when using GitBash. From a sub-folder of the “app” folder, I tried to create a component but it simply ended up in the “app” folder. The fact that I created the component from the sub-folder was ignored.

term_screen

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dagger 2 component not generated - Stack Overflow
I have done build / rebuild / clean / restart project. I have a Component class where I inject objects and a ModuleClass...
Read more >
ComponentName of type ComponentType was named in ...
Deployment Error: 'ComponentName of type ComponentType was named in package.xml, but was not found in zipped directory' ...
Read more >
How to generate component in subdirectory or specific folder ...
steps to generate component in a specific folder in Angular. 1. Open terminal at Angular project root directory. 2.
Read more >
Learning the Basics - Gradle User Manual
Gradle exposes an API to declare what a repository may or may not contain. There are different use cases for it: performance, when...
Read more >
Build System - ESP32 - — ESP-IDF Programming Guide v5.0 ...
The toolchain for compilation is not part of the project. The toolchain should be ... Defaults to all components found in the COMPONENT_DIRS...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found