Skip to content

Can not install angular-cli on Ubuntu 18.04 #14684

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
meightythree opened this issue Jun 6, 2019 · 12 comments · Fixed by #14765
Closed

Can not install angular-cli on Ubuntu 18.04 #14684

meightythree opened this issue Jun 6, 2019 · 12 comments · Fixed by #14765
Labels
area: @angular/cli freq1: low Only reported by a handful of users who observe it rarely severity5: regression type: bug/fix
Milestone

Comments

@meightythree
Copy link

🐞 Bug report

Command (mark with an x)

I guess it affects "all" because I couldn't even install the cli.

- [ ] new
- [ ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Is this a regression?

It isntalls with 7.x version

Yes, the previous version in which this bug was not present was: ....

Description

Using the angular cli installation command: sudo npm install -g @angular/cli

I get this error: https://pastebin.com/aqDXNBM0

There's no such file '/home/user/.angular-config.json', I have tried creating it by the 'touch' command, but it gave another error: https://pastebin.com/xZNQUwAa

I have tried 'npm cache clean --force' command with the same results.

I tried to install a previous verison of Angular with the 'sudo npm install -g @angular/[email protected]' and it installed it however it throws "Workspace needs to be loaded before it is used.", I guess it's because of the angular-config.json I've created...

A clear and concise description of the problem...

🔬 Minimal Reproduction

sudo npm i -g @angular/cli

🔥 Exception or Error

I have linked the errors above.





🌍 Your Environment



Couldn't run ng version with angular 8.x

ng version with 7.x
Angular CLI: 7.3.9
Node: 12.4.0
OS: linux x64
Angular: 
... 

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.13.9
@angular-devkit/core         7.3.9
@angular-devkit/schematics   7.3.9
@schematics/angular          7.3.9
@schematics/update           0.13.9
rxjs                         6.3.3
typescript                   3.2.4



Anything else relevant?

@alan-agius4
Copy link
Collaborator

alan-agius4 commented Jun 6, 2019

The relevant part of the log is:

(node:5022) UnhandledPromiseRejectionWarning: Error: EACCES: permission denied, open '/home/user/.angular-config.json'
    at Object.openSync (fs.js:447:3)
    at Object.writeFileSync (fs.js:1206:35)
    at createGlobalSettings (/usr/lib/node_modules/@angular/cli/utilities/config.js:65:10)
    at Object.getWorkspaceRaw (/usr/lib/node_modules/@angular/cli/utilities/config.js:73:26)
    at setAnalyticsConfig (/usr/lib/node_modules/@angular/cli/models/analytics.js:288:43)
    at Object.promptGlobalAnalytics (/usr/lib/node_modules/@angular/cli/models/analytics.js:326:9)
    at processTicksAndRejections (internal/process/task_queues.js:89:5)
(node:5022) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:5022) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
+ @angular/cli@8.0.1

It seems that you don't have write permissions on that path.

@meightythree
Copy link
Author

Thanks for the response!
But how come I could install a previous version of the cli?

@alan-agius4
Copy link
Collaborator

alan-agius4 commented Jun 6, 2019

Because this logic is part of version 8.

That said, we should probably handle it more gracefully and not bail out when the CLI doesn't have permission to write a global config.

//cc @clydin, thoughts?

@alan-agius4 alan-agius4 added area: @angular/cli freq1: low Only reported by a handful of users who observe it rarely severity5: regression labels Jun 6, 2019
@ngbot ngbot bot modified the milestone: needsTriage Jun 6, 2019
@filipesilva
Copy link
Contributor

It's worth mentioning that you should not install global npm modules with sudo. Please have a look at the fixing npm permissions page.

@ngbot ngbot bot modified the milestones: needsTriage, Backlog Jun 6, 2019
@meightythree
Copy link
Author

Thank you @filipesilva, I think I will check out npx.

@mgechev
Copy link
Member

mgechev commented Jun 11, 2019

Instead of failing can we throw a warning and fallback to default config (analytics off).

Alternatively, brew handles this really well by giving you a hint about what command you should run to fix your permissions.

@codeByAshu01
Copy link

(node:18440) UnhandledPromiseRejectionWarning: Error: EACCES: permission denied, open '/home/ashu/.angular-config.json'
at Object.openSync (fs.js:436:3)
at Object.writeFileSync (fs.js:1187:35)
at createGlobalSettings (/usr/lib/node_modules/@angular/cli/utilities/config.js:65:10)
at Object.getWorkspaceRaw (/usr/lib/node_modules/@angular/cli/utilities/config.js:73:26)
at setAnalyticsConfig (/usr/lib/node_modules/@angular/cli/models/analytics.js:288:43)
at Object.promptGlobalAnalytics (/usr/lib/node_modules/@angular/cli/models/analytics.js:326:9)
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:18440) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:18440) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

  • @angular/[email protected]
    added 228 packages from 175 contributors in 22.457s
    ashu@ashu-HP-Pavilion-G42-Notebook-PC:~$

@clydin
Copy link
Member

clydin commented Jun 17, 2019

Not being able to write to your own home directory typically signifies a system-wide configuration issue.

Note, however, that the next patch release of the Angular CLI will not crash in this situation.

@codeByAshu01
Copy link

Not being able to write to your own home directory typically signifies a system-wide configuration issue.

Note, however, that the next patch release of the Angular CLI will not crash in this situation.

then any alternate way to fix this issue as of now

@ankitmaurya001
Copy link

I am also facing the same issue. Any way to fix this?

@frkntony
Copy link

Well, I kinda hate npm tbh. However, I was installing my tools via it for a long time. That has changed.

My solution is to use yarn:
sudo npm uninstall -g @angular/cli
sudo yarn global add @angular/cli

Works like a charm.

@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 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: @angular/cli freq1: low Only reported by a handful of users who observe it rarely severity5: regression type: bug/fix
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants