You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Was this an app that wasn't created using the CLI? What change did you do on your code? etc.
mkdir sample
cd sample
yarn add @nagular/cli
node_modules/.bin/ng new sample -dir=.
The log given by the failure.
Normally this include a stack trace and some more information.
You cannot use the new command inside an Angular CLI project.
Mention any other details that might be useful.
This is because the command checks for whether it's in project by looking for the package @angular/cli under node_modules
I think it should be looking for config file .angular-cli.json instead
This is important as ng init / ng update is now gone. It allows me to use the CLI without global installation, earlier I used ng init for this
I'm NOT asking for this to work in existing CLI project. This is NOT a request to make new act as init. The scenario I'm asking to support is when the package exists, but no other files like package.json or .angular-cli.json are present, that is, no Angular CLI project in the folder
Happy to look at implementation if we agree we want to make that change, which is detecting project presence based on config file .angular-cli.json not presence of node_modules/@angular/cli/.
You have an node_modules folder somewhere in your path (a parent directory or something). Look for a package.json file somewhere, or a node_modules directory. Delete those and you'll be fine.
It's part of the Angular CLI project, and we modified the file a few times already. If we agree on the principle that the check should be based on presence of Angular CLI config file, that'd be awesome.
We have diverged from the ember CLI anyway (Ember still has an init command for example, although again, this is NOT aimed at making new like init). This will enable #4768 for example.
I'm using the v.1.0.0-rc1 and still having the same issue. In order to initialize a project with local cli by
running:
npm init
npm install @angular/cli --save-dev
modifying package.json adding script: "ng": "node_modules\.bin\ng"
and running:
npm run ng -- new my-project -dir=.
I still get: "You cannot use the new command inside an Angular CLI project."
There are tons of practical reasons why this approach is for us better than having cli globally installed
Activity
Meligy commentedon Feb 16, 2017
Happy to look at implementation if we agree we want to make that change, which is detecting project presence based on config file
.angular-cli.jsonnot presence ofnode_modules/@angular/cli/.hansl commentedon Feb 16, 2017
You have an
node_modulesfolder somewhere in your path (a parent directory or something). Look for apackage.jsonfile somewhere, or anode_modulesdirectory. Delete those and you'll be fine.Most of the time those are in your HOME folder.
Meligy commentedon Feb 16, 2017
@hansl did you check the repro steps?
Meligy commentedon Feb 17, 2017
@hansl I double checked - I don't.
But anyway, are you suggesting that the mentioned steps above are not supposed to bring the mentioned message?
hansl commentedon Feb 17, 2017
OH okay. No I didn't. I just see those and copy-paste the message lol
hansl commentedon Feb 17, 2017
The Angular CLI does use node_modules to detect if it's in a project. This is by design and unlikely to change (it's Ember-CLI specific logic).
Meligy commentedon Feb 17, 2017
I can see the check is made here https://github.com/angular/angular-cli/blob/master/packages/%40angular/cli/ember-cli/lib/models/project.js#L117
It's part of the Angular CLI project, and we modified the file a few times already. If we agree on the principle that the check should be based on presence of Angular CLI config file, that'd be awesome.
We have diverged from the ember CLI anyway (Ember still has an
initcommand for example, although again, this is NOT aimed at makingnewlikeinit). This will enable #4768 for example.feat(@angular/cli): allow to create new projects in existing directory
Meligy commentedon Feb 22, 2017
Thanks a lot @hansl and @filipesilva 💯
machucarro commentedon Mar 10, 2017
I'm using the v.1.0.0-rc1 and still having the same issue. In order to initialize a project with local cli by
running:
npm init
npm install @angular/cli --save-dev
modifying package.json adding script: "ng": "node_modules\.bin\ng"
and running:
npm run ng -- new my-project -dir=.
I still get: "You cannot use the new command inside an Angular CLI project."
There are tons of practical reasons why this approach is for us better than having cli globally installed
filipesilva commentedon Mar 13, 2017
@machucarro I just tried this myself and it works. See below for a log of what I did.
Maybe you have a CLI config file somewhere up in the directory tree?
feat(@angular/cli): allow to create new projects in existing directory
angular-automatic-lock-bot commentedon Sep 6, 2019
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.
feat(@angular/cli): allow to create new projects in existing directory