Please provide us with the following information:
Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?)
Windows 8.1
Please run
ng --version. If there's nothing outputted, please run in a Terminal:node --versionand paste the result here:
@angular/cli: 1.0.0-beta.31
node: 6.9.4
os: win32 x64
@angular/cli: 1.0.0-beta.31
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=.
Normally this include a stack trace and some more information.
You cannot use the new command inside an Angular CLI project.
@angular/cli under node_modules.angular-cli.json insteadng init / ng update is now gone. It allows me to use the CLI without global installation, earlier I used ng init for thisnew 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
Thanks! We'll be in touch soon.
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.
Most of the time those are in your HOME folder.
@hansl did you check the repro steps?
@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?
OH okay. No I didn't. I just see those and copy-paste the message lol
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).
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 init command for example, although again, this is NOT aimed at making new like init). This will enable #4768 for example.
Thanks a lot @hansl and @filipesilva 馃挴
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
@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?
kamik@T460p MINGW64 /D/sandbox
$ mkdir local-proj
kamik@T460p MINGW64 /D/sandbox
$ cd local-proj/
kamik@T460p MINGW64 /D/sandbox/local-proj
$ npm install @angular/cli
# ...
kamik@T460p MINGW64 /D/sandbox/local-proj
$ $(npm bin)/ng new local-proj --dir=./ --skip-install
installing ng
create .editorconfig
create README.md
create src\app\app.component.css
create src\app\app.component.html
create src\app\app.component.spec.ts
create src\app\app.component.ts
create src\app\app.module.ts
create src\assets\.gitkeep
create src\environments\environment.prod.ts
create src\environments\environment.ts
create src\favicon.ico
create src\index.html
create src\main.ts
create src\polyfills.ts
create src\styles.css
create src\test.ts
create src\tsconfig.app.json
create src\tsconfig.spec.json
create src\typings.d.ts
create .angular-cli.json
create e2e\app.e2e-spec.ts
create e2e\app.po.ts
create e2e\tsconfig.e2e.json
create .gitignore
create karma.conf.js
create package.json
create protractor.conf.js
create tsconfig.json
create tslint.json
Successfully initialized git.
You can `ng set --global packageManager=yarn`.
Project 'local-proj' successfully created.
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._
Most helpful comment
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.