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

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

Open Ionaru opened this issue 9 years ago • 17 comments

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.

Ionaru avatar Feb 03 '17 15:02 Ionaru

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

beeman avatar Feb 03 '17 15:02 beeman

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

Ionaru avatar Feb 03 '17 15:02 Ionaru

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

beeman avatar Feb 03 '17 15:02 beeman

Do you have the same CLI version?

Ionaru avatar Feb 03 '17 15:02 Ionaru

❯ 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

beeman avatar Feb 03 '17 15:02 beeman

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

Ionaru avatar Feb 03 '17 15:02 Ionaru

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

beeman avatar Feb 03 '17 15:02 beeman

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

Ionaru avatar Feb 03 '17 15:02 Ionaru

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

rinoldit avatar Oct 10 '17 12:10 rinoldit

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

vickytechkey avatar Nov 12 '17 03:11 vickytechkey

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

filipesilva avatar Jan 03 '18 10:01 filipesilva

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

ASrima avatar Jan 03 '18 17:01 ASrima

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 avatar Jan 07 '18 04:01 jhonazsh

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.

ASrima avatar Jan 07 '18 06:01 ASrima

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 :)

jhonazsh avatar Jan 07 '18 16:01 jhonazsh

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.

Crystyanno avatar Mar 15 '18 12:03 Crystyanno

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.