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 mralexivy opened this issue 10 years ago • 33 comments

Installed latest version of angular-cli on my windows pc trying just to create new project with: ng new project_name getting error: You cannot use the new command inside an angular-cli project. Tried to remove , reinstall with npm cache clean, nothing helps :( clibug

OS?

Windows 10 x64.

Versions.

angular-cli: 1.0.0-beta.17 node: 6.4.0 os: win32 x64

Repro steps.

ng new project_name

The log given by the failure.

Normally this include a stack trace and some more information.

mralexivy avatar Oct 21 '16 14:10 mralexivy

After deleting package.json file at user folder, it worked. (Windows 10)

rcarnauba avatar Dec 29 '17 16:12 rcarnauba

I had the similar problem and nothing was working out but then when I ran cmd as administrator it worked for me. First run the Command Prompt as administrator ans then create the new project and if it still doesn't create the project run the code rm -r -f // and then run ng new and then run ng serve and it should work (use this method only if the 1st part doesn't work). If nothing works just uninstall node and every other file related to it th and run the previous code again it will work. Also open the editor as an administrator to edit your code otherwise you might run into permission issues.

ASrima avatar Jan 03 '18 05:01 ASrima

I'm using MacOS and I had this problem today... The way I fixed it was:

1 - I had no idea why, but there was a node_modules and a package.json on my home folder... I removed them; 2 - I also removed a node_modules and package.json from my current project folder 3 - Then, ng new project-name worked :)

I hope it helps somebody else...

p.s.: Please, angular@cli people, take a look at this weird thing going on... I don't know why angular@cli is creating such files in the home o.O

andreobueno avatar Jan 31 '18 08:01 andreobueno

I had the same problem, i deleted the package.json file from the folder, after that it works :)

devssharma avatar Feb 03 '18 20:02 devssharma

I had the same problem, i deleted the package.json file from the folder, after that it works :) me too! working now!!!!!!!!!!

breninrice avatar Feb 27 '18 19:02 breninrice

actually, you don't need to delete the whole package.json file, just if you can delete angular cli in devdependendy line, it will work but don't forget to save the json file in your editor, then restart your terminal. that how it worked for me

rajendharitguy avatar Mar 10 '18 19:03 rajendharitguy

try first : you just need to remove "@angular/cli": "1.6.1", "@angular/compiler-cli": "^5.2.9",

from package.json

or _**

Search on the root folder for a file called package.json then delete it .

It will solve the problem.

**_

fahedalh avatar Mar 16 '18 11:03 fahedalh

I had the same problem. It works fine now after deleting package.json thanks a lot you guys. May I know the actual use of that file? How the existence of it cause this problem... I have some other file "package-lock.json" which bothers me than this. ;)

Piuu avatar Mar 27 '18 18:03 Piuu

Hi All, I have faced this issue but got this solution

  1. Create a dir test
  2. Cd test
  3. run npm init command
  4. ng new Ang5App
  5. Finally, it works for me

vivekgupta135 avatar Apr 09 '18 06:04 vivekgupta135

thanks a lot ,it works for me .Allah bless you

mkadhim avatar May 21 '18 04:05 mkadhim

I haven't any package.json file in my root directory or node_modules or angular.json and I still can't run ng new something inside of a CLI project and the new project has to be inside of this CLI project. So what I have to do?

thiagofrancisquete avatar Aug 10 '18 19:08 thiagofrancisquete

excecute npm install --save-dev @angular/cli@latest into dir work.. (example: Desktop)

rheineo avatar Mar 20 '19 18:03 rheineo

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.