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

Is there a file called angular-cli.json on your desktop?

grizzm0 avatar Oct 21 '16 15:10 grizzm0

No, there is no angular-cli.json on my desktop clibug2

mralexivy avatar Oct 21 '16 15:10 mralexivy

What if you try to run this command in another folder?

ogix avatar Oct 23 '16 19:10 ogix

Is there a file called package.json alone in other places ? Deletes it , maybe solve the problem. 2016-10-27 1 43 53

JiaHongL avatar Oct 27 '16 05:10 JiaHongL

Somewhere in the folders above your current one there is either a node_modules/ folder or a angular-cli.json. Basically the command is detecting that you are already a npm project.

Try checking these folders for node_modules/orangular-cli.json` and delete it:

C:\
C:\Users\
C:\Users\Admin-PC\
C:\Users\Admin-PC\Desktop\

Alternatively, make your project in another folder e.g. C:\test\.

filipesilva avatar Nov 02 '16 18:11 filipesilva

after I delete an exist package.sjon it work for me 10x 👍

ofirrifo avatar Dec 10 '16 13:12 ofirrifo

If you are using linux, go to home and find package.json and remove that. Keep rocking :+1:

nikhilknoldus avatar Dec 12 '16 12:12 nikhilknoldus

on macOs I did what @nikhilknoldus said about removing the package.json in the home directory it worked for me.

sherifsaleh avatar Apr 19 '17 20:04 sherifsaleh

worked for me after deleting package.json file

sumanthkumar93 avatar May 22 '17 21:05 sumanthkumar93

Faced same issue but didn't work for me if I deleted Package.json from home directory

sahilkatia avatar Jun 05 '17 00:06 sahilkatia

I have the same issue. I am on a different drive. it's one folder removed from the root. There is no package.json in the root. There is no node_module in the root. I am using windows 10, node 7.4.0, @angular/cli 1.2.0

Any ideas or reasons why? This is becoming such a pain.

f0ru0l0rd avatar Jul 06 '17 13:07 f0ru0l0rd

Yup. Me, too. Empty directory.

bluebaroncanada avatar Jul 07 '17 00:07 bluebaroncanada

To above: If you are using windows 10, do a global search for package.json to see if you have it in your destination folder's parent folder. I found mine in c:\user\myname and once I removed it everything works fine.

fanfanpsu avatar Jul 09 '17 03:07 fanfanpsu

It's basing its decision on whether you have "@angular/cli": "^1.3.1" as a dependency in your package file. This is usually because you're creating an angular project inside another project that may or may not be angular. If you get the warning:

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

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

don't do what it says. It'll be part of the package.json when you ng new ....

bluebaroncanada avatar Aug 23 '17 18:08 bluebaroncanada

Guys I have a similar problem I have created a complete new folder included my package.json and node_modules from npm and when I tried to create client folder using ng new client, the error was you cant new command inside Angular CLI project (This was in my D Drive) Then I changed my project drive to C: and copied and pasted all the files except package.json and tried ng new client it worked and client folder is created. But when I tried to start the server using npm start, another error saying package.json file is missing??

Any solution for this confusion? Thanks.

pavankumar58 avatar Sep 20 '17 04:09 pavankumar58

In Mac, press Shift+Command+H or select Finder then press Go option on top toolbar and finally select Home option. Now select package.json,package-lock.json file and delete both the files.

Restart your terminal and you are ready to go.

rajatmohanty avatar Oct 10 '17 09:10 rajatmohanty

If you are using Linux, go to home and find package.Json and remove that.

beginfarming avatar Oct 20 '17 06:10 beginfarming

I was trying to install angular as the front-end, for my existing back-end project. E.g. my-project/angular-app. Was getting what @bluebaroncanada mentioned. What worked was ng new outside my existing project.

leotm avatar Nov 11 '17 17:11 leotm

You must initialize npm before creating new angular project, i have the same problem but when i try to init npm, it works

Wakugumi avatar Nov 24 '17 14:11 Wakugumi

I was facing same problem. I deleted package.json from project and applied necessary command, It worked.

shahrishabhptechnical avatar Dec 14 '17 04:12 shahrishabhptechnical