Angular-cli: CLI with --directory option creates application in wrong directory

Created on 25 Jun 2017  路  2Comments  路  Source: angular/angular-cli

Bug Report or Feature Request (mark with an x)

- [x ] bug report -> please search issues before submitting
- [ ] feature request

Versions.

Output from: ng --version.

@angular/cli: 1.1.3
node: 7.2.1
os: win32 x64

Repro steps.

  1. Create a directory 'project' and run 'npm init -y' from the command prompt or power shell.
mkdir project
cd project
npm init -y
  1. Create a directory 'client' inside 'project' folder and run 'ng new my-app --directory . --skip-install'
mkdir client
cd client
ng new my-app --directory . --skip-install

User expectation at this point is that the CLI to create a new app in the current working directory, that is 'client' directory. But the CLI tries to create the app at the parent directory 'project'.

Without any supplied value (.) to --directory option, app is created in the parent directory where a package.json exists.

The log given by the failure.

Output from above ng new command:

Unable to find "@angular/cli" in devDependencies.

Please take the following steps to avoid issues:
"npm install --save-dev @angular/cli@latest"

installing ng
? Overwrite package.json? (yndH)

Desired functionality.

CLI with --directory option assumes current working directory '.' (single period) as the root parent where a package.json exists.

In a single monolithic repository, it is important to differentiate relative paths. With the command supplied in the repro steps, the app should be created in the client directory.

Can someone please point me to the --directory documentation?

Mention any other details that might be useful.

It confuses CLI, if there is a package.json exists at the root directory. Even ng -v will result in below warning

Unable to find "@angular/cli" in devDependencies.

Please take the following steps to avoid issues:
"npm install --save-dev @angular/cli@latest"

Please have a look at below steps:

mkdir project
cd project
npm init -y
mkdir client
cd client
mkdir web-client
ng new web-app --directory ./web-client --skip-install

User expectation is to get the new app created inside project/client/web-client directory. But the web-app is created inside root folder 'project' since there is a package.json.

easy (hours) 2 (required) regression bufix

Most helpful comment

@filipesilva
Upgraded NPM, Node along with CLI to the latest version. This works like a charm with the below version of CLI..

@angular/cli: 1.2.0
node: 8.1.3
npm: 5.0.3
os: win32 x64
mkdir project
cd project
npm init -y
mkdir client
cd client
mkdir web-client
ng new web-app --directory=./web-client -si

Above ng new successfully created the app in web-client directory. Getting below warning, but that's not a problem at all.

Unable to find "@angular/cli" in devDependencies.
Please take the following steps to avoid issues:
"npm install --save-dev @angular/cli@latest

Since this is working on the latest version of CLI, I am closing this issue. Thanks.

All 2 comments

@filipesilva
Upgraded NPM, Node along with CLI to the latest version. This works like a charm with the below version of CLI..

@angular/cli: 1.2.0
node: 8.1.3
npm: 5.0.3
os: win32 x64
mkdir project
cd project
npm init -y
mkdir client
cd client
mkdir web-client
ng new web-app --directory=./web-client -si

Above ng new successfully created the app in web-client directory. Getting below warning, but that's not a problem at all.

Unable to find "@angular/cli" in devDependencies.
Please take the following steps to avoid issues:
"npm install --save-dev @angular/cli@latest

Since this is working on the latest version of CLI, I am closing this issue. Thanks.

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._

Was this page helpful?
0 / 5 - 0 ratings