Angular-cli: CLI error when found 'package.json' has no 'devDependencies' entry

Created on 27 Feb 2017  路  4Comments  路  Source: angular/angular-cli

Please provide us with the following information:

OS?

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

Mac OS X El Capitan

Versions.

Please run ng --version. If there's nothing outputted, please run in a Terminal: node --version and paste the result here:

1.0.0-rc.0

Repro steps.

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

Run any cli command in a directory that contains a package.json or a subdirectory whose parent contains a package.json.

The log given by the failure.

Normally this include a stack trace and some more information.

/Users/Greg/.nvm/versions/node/v6.10.0/lib/node_modules/@angular/cli/bin/ng:95
const hasOldDevDep = !!packageJsonProject.devDependencies['angular-cli'];
^

TypeError: Cannot read property 'angular-cli' of undefined
at Object. (/Users/Greg/.nvm/versions/node/v6.10.0/lib/node_modules/@angular/cli/bin/ng:95:60)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:509:3

Mention any other details that might be useful.

The package.json file in question was in my HOME folder (I think Yarn put it there- #4762 pointed me in the right direction) and it only had a dependencies section. Once I added a devDependencies section the CLI worked properly.


Thanks! We'll be in touch soon.

Most helpful comment

Why is it showing a warning even though I have CLI installed globally.

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

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

@angular/cli: 1.1.3
node: 7.2.1
os: win32 x64

All 4 comments

@hansl I can see this issue has been closed. But is the code released ? I am trying to install it but still the same error.

sudo npm install -g @angular/cli@latest

@anantgoldie Released with RC.1 https://github.com/angular/angular-cli/blob/master/CHANGELOG.md#100-rc1-2017-03-03

Why is it showing a warning even though I have CLI installed globally.

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

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

@angular/cli: 1.1.3
node: 7.2.1
os: win32 x64

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