Angular-cli: You cannot use the new command inside an Angular CLI project.

Created on 3 Feb 2017  Β·  17Comments  Β·  Source: angular/angular-cli

OS?

Linux Ubuntu 16.10

Versions.

node: 7.2.0
os: linux x64
@angular/cli: 1.0.0-beta.30

Repro steps.

npm install -g @angular/cli
mkdir newApp
cd newApp
ng new

The log given by the failure.

You cannot use the new command inside an Angular CLI project.
But the folder is completely empty.

Most helpful comment

Completely removing @angular/cli and reinstalling it seems to have done the trick.

All 17 comments

@Ionaru can you check if you still have an angular-cli package installed globally? If you, please remove it.

And please verify if there is a mention of angular-cli in you package.json.

Here's my npm list output, there is no package.json in the folder I am running 'ng new' in.

> npm -g list --depth=0
/usr/local/lib
β”œβ”€β”€ @angular/[email protected]
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected]
└── [email protected]
> which ng
/usr/local/bin/ng

That file points to ../lib/node_modules

Ok, that does not seem to be the case.

So of you want to create the project dir yourself, you should use ng init instead of ng new

mkdir newApp
cd newApp
ng init

Of use ng new like this:

ng new newApp

edit
When I run your commands in the steps I get this message:

The "ng new" command requires a name argument to be specified. For more details, use "ng help".

Do you have the same CLI version?

❯ ng --version

                             _                           _  _
  __ _  _ __    __ _  _   _ | |  __ _  _ __         ___ | |(_)
 / _` || '_ \  / _` || | | || | / _` || '__|_____  / __|| || |
| (_| || | | || (_| || |_| || || (_| || |  |_____|| (__ | || |
 \__,_||_| |_| \__, | \__,_||_| \__,_||_|          \___||_||_|
               |___/
@angular/cli: 1.0.0-beta.30
node: 7.5.0
os: darwin x64
@angular/common: 2.4.6
@angular/compiler: 2.4.6
@angular/core: 2.4.6
@angular/forms: 2.4.6
@angular/http: 2.4.6
@angular/platform-browser: 2.4.6
@angular/platform-browser-dynamic: 2.4.6
@angular/router: 3.4.6
@angular/cli: 1.0.0-beta.30
@angular/compiler-cli: 2.4.6

You have Angular installed globally as well, is that necessary?

No, it's not installed globally. I run this command from inside the project dir that I just created reproducing your steps.

It's not needed either, the only global dependency is @angular/cli

Completely removing @angular/cli and reinstalling it seems to have done the trick.

hello friends I got the issues when trying to do " ng new MyApp1 "
" You cannot use the new command inside an Angular CLI project "

remove the package.json file in the following path
C:\Users\name of user\node_modules\@angular\cli
its work me fine

@ASrima rm -r -f // might will probably delete a bunch of things that you don't expect. It's a bad idea to advise people to run this command.

Hi filipesilva thank you for the advice. I only suggest to run it if nothing works and you really need to create the project otherwise you can try running the Command Prompt as administrator and then create the new project

Hi i have the same problem. I need a solution. please help me!. I have Angular CLI version 1.6.3. I suppose that is the latest version because i used the command npm install -g @angular/cli but nothing.

>ng new my-project
you cannot use the new command inside an angular cli project

And i used this too:

>mkdir my-project
>cd my-project
>ng init

But nothing.

Please help me! - My OS is Windows x64.

jhonazsh Run the Command Prompt as administrator and then create the new project and it should work and when you use the IDE open it as administrator to be able to edit and save the project. Also use the latest version of node if nothing works uninstall and reinstall the latest version and then follow the same process of running CMD and IDE as administrator.

Hi @ASrima I uninstalled node and i installed the latest version for node and i installed the latest version for Angular CLI and works. Thanks for your help. πŸ‘ i follow you on github :)

Se estiver iniciar a instalaΓ§Γ£o usando o "CMD" como Administrador vocΓͺ sΓ³ irΓ‘ conseguir criar novos projetos da mesma forma sempre no modo Adm.

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

Related issues

MateenKadwaikar picture MateenKadwaikar  Β·  3Comments

JanStureNielsen picture JanStureNielsen  Β·  3Comments

donaldallen picture donaldallen  Β·  3Comments

jmurphzyo picture jmurphzyo  Β·  3Comments

ericel picture ericel  Β·  3Comments