Skip to content

Cant use NG #5116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dertuerke opened this issue Feb 28, 2017 · 8 comments
Closed

Cant use NG #5116

dertuerke opened this issue Feb 28, 2017 · 8 comments
Assignees

Comments

@dertuerke
Copy link

dertuerke commented Feb 28, 2017

Please provide us with the following information:

OS?

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

Mac OSX Sierra

Versions.

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

Node: 7.6.0

Repro steps.

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

I cant use ng --version, if i use yarn global add.

The log given by the failure.

Normally this include a stack trace and some more information.

/Users/burak/.config/yarn/global/node_modules/@angular/cli/bin/ng:95
const hasOldDevDep = !!packageJsonProject.devDependencies['angular-cli'];
^

TypeError: Cannot read property 'angular-cli' of undefined
at Object. (/Users/burak/.config/yarn/global/node_modules/@angular/cli/bin/ng:95:60)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.runMain (module.js:605:10)
at run (bootstrap_node.js:422:7)
at startup (bootstrap_node.js:143:9)
at bootstrap_node.js:537:3

Mention any other details that might be useful.


Thanks! We'll be in touch soon.

@sumitarora
Copy link
Contributor

@dertuerke which version of CLI you are using currently when you added yarn?

@dertuerke
Copy link
Author

@sumitarora i use yarn 0.21.3. If use use npm i get NO problems

@antoinegomez
Copy link

Same here. It tries to read my package.json that does not have any devDep so it crashes.

Here is a line to patch:

const packageJsonProject = Object.assign({ dependencies: {}, devDependencies: {} }, require(packageJsonProjectPath));

File: cli/bin/ng
Line 93

File on my system for reference:
~/.nvm/versions/node/v6.9.1/lib/node_modules/@angular/cli/bin/ng

@clrajapaksha
Copy link

I am facing to the same issue. Please help.

`C:\Users\chathuranga_08290\AppData\Roaming\npm\node_modules@angular\cli\bin\ng:95
const hasOldDevDep = !!packageJsonProject.devDependencies['angular-cli'];
^

TypeError: Cannot read property 'angular-cli' of undefined
at Object. (C:\Users\chathuranga_08290\AppData\Roaming\npm\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
`

@clrajapaksha
Copy link

I resolved the issue by doing following things,
uninstall node
reinstall node
npm cache clear
npm install -g @angular/cli
ng new myapp

@dertuerke
Copy link
Author

@clrajapaksha the problem comes with YARN. If you use Yarn to install the cli global.

@sumitarora sumitarora self-assigned this Mar 6, 2017
@sumitarora
Copy link
Contributor

Fixed with this #5074

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants