Angular-cli: "You have to be inside an angular-cli project in order to use the build command." due to global and local cli version being out of sync

Created on 3 Feb 2017  路  10Comments  路  Source: angular/angular-cli

note: this was filed by @IgorMinar from wards computer, so blame @IgorMinar for any pain this issue has caused to you.

OS?

Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?)

MacOS

Versions.

global:

$ ng version

@angular/cli: 1.0.0-beta.29
node: 6.9.5
os: darwin x64
@angular/common: 2.4.5
@angular/compiler: 2.4.5
@angular/core: 2.4.5
@angular/forms: 2.4.5
@angular/http: 2.4.5
@angular/material: 2.0.0-beta.1
@angular/platform-browser: 2.4.5
@angular/platform-browser-dynamic: 2.4.5
@angular/router: 3.4.5
@angular/compiler-cli: 2.4.5

local:

$ $(yarn bin)/ng version

angular-cli: 1.0.0-beta.28.3
node: 6.9.5
os: darwin x64
@angular/common: 2.4.5
@angular/compiler: 2.4.5
@angular/core: 2.4.5
@angular/forms: 2.4.5
@angular/http: 2.4.5
@angular/material: 2.0.0-beta.1
@angular/platform-browser: 2.4.5
@angular/platform-browser-dynamic: 2.4.5
@angular/router: 3.4.5
@angular/compiler-cli: 2.4.5

Repro steps.

Was this an app that wasn't created using the CLI? What change did you do on your code? etc.

$ ng build
You have to be inside an angular-cli project in order to use the
 build command.

but if I do:

$ $(yarn bin)/ng build
.... works just fine ....

Most helpful comment

You should run "npm install -g @angular/cli@latest". It solved for me.

All 10 comments

fyi, to resolve this problem we did the following:

yarn remove angular-cli
yarn add @angular/cli --dev

@wardbell the local package.json should be updated to have "@angular/cli": "^1.0.0-beta.29", instead of "angular-cli": "1.0.0-beta.28.3".

does not work here, still having the error

@victorblq can you remove node_modules and npm install ?

I fix changing the package.json file this way:
from:

 "devDependencies": {
    "@angular/compiler-cli": "2.4.5",
    "angular-cli": "1.0.0-beta.26",
    ...

to:

"devDependencies": {
    "@angular/cli": "1.0.0-beta.29",
    "@angular/compiler-cli": "^2.3.1",
    ...

I removed this line too:
"lint": "tslint \"src/**/*.ts\" --project src/tsconfig.json --type-check && tslint \"e2e/**/*.ts\" --project e2e/tsconfig.json --type-check",
and the angular-cli.json like @hansl said.
After that rm -rf node_modules and npm install and ng serve works.
I don't know if it's relevant, but I did it all in a existing project, not a new one.

@victorblq yep, only existing packages (created by angular-cli, ran with@angular/cli are affected).

The next beta adds support for both though.

You should run "npm install -g @angular/cli@latest". It solved for me.

@azollai Thanks

Yes this worked for me as well thanks
npm install -g @angular/cli@latest

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

Was this page helpful?
0 / 5 - 0 ratings