Angular CLI v6.0.8 won't install - node.js

I've installed NodeJS via PPA on Ubuntu 18.04. However when running sudo npm install -g #angular/cli I get the error at the bottom of this post.
I am using node v10.6.0 and npm v6.1.0. I have tried these commands, with no luck:
A) sudo npm install -g #angular/cli#latest
B) npm install -g #angular/cli (no sudo)
C) sudo npm install -g angular-cli --unsafe-perm=true
One thing I noticed was that in case C it actually installs and works when running as sudo. But it doesn't work as a regular user ("bash: ng: command not found").
I have checked my PATH env variable and have confirmed that the result of npm bin -g (/usb/bin) is indeed in my PATH for all users.
Any help would be very much appreciated.
me#laptop:~$ sudo npm install -g #angular/cli
[sudo] password for me:
/usr/bin/ng -> /usr/lib/node_modules/#angular/cli/bin/ng
> #angular/cli#6.0.8 postinstall /usr/lib/node_modules/#angular/cli
> node ./bin/ng-update-message.js
internal/modules/cjs/loader.js:583
throw err;
^
Error: Cannot find module '/usr/lib/node_modules/#angular/cli/bin/ng-update-message.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
at Function.Module._load (internal/modules/cjs/loader.js:507:25)
at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
at startup (internal/bootstrap/node.js:236:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:560:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! #angular/cli#6.0.8 postinstall: `node ./bin/ng-update-message.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the #angular/cli#6.0.8 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

FOUND IT! After much digging around I realized this was a permissions issue. A system-wide umask in the PAM module (Ubuntu) was set to create files and folders with more restrictive permissions than usual. This is what I did to get back to normal and get Angular CLI installed:
sudo vi /etc/pam.d/common-session
Then change this line: session optional pam_umask.so umask=077
To this: session optional pam_umask.so
Reboot, then: sudo npm install -g #angular/cli
Et VoilĂ !

Related

Install expo cli errors at the end of install

So I'm following this tutorial to try and learn React Native: https://www.youtube.com/watch?v=qSRrxpdMpVc
And in the tutorial he shows to install expo cli using the line
'npm install expo-cli --global'
But when i run that line, i get a whole bunch of warnings saying for example:
npm WARN deprecated topo#3.0.3: This module has moved and is now available at #hapi/topo. Please update your dependencies as this version is no longer maintained an may contain bugs and security issues.
In the tutorial he says to ignore this but at the end of the install i get this error:
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! envsub#3.1.0 postinstall: `test -d .git && cp gitHookPrePush.sh .git/hooks/pre-push || true`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the envsub#3.1.0 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Alex\AppData\Roaming\npm-cache\_logs\2019-12-06T01_25_52_024Z-debug.log
and then when i try to run the line 'expo init first-app' to create a project i get this error:
Error: Cannot find module 'C:\Users\Alex\AppData\Roaming\npm\node_modules\expo-cli\bin\expo.js'
[90m at Function.Module._resolveFilename (internal/modules/cjs/loader.js:797:15)[39m
[90m at Function.Module._load (internal/modules/cjs/loader.js:690:27)[39m
[90m at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10)[39m
[90m at internal/main/run_main_module.js:17:11[39m {
code: [32m'MODULE_NOT_FOUND'[39m,
requireStack: []
}
I also found a similar question with an answer of try running
npm cache clean --force
npm install -g expo-cli
So i tried that but it didnt work.
Does anyone know why i would be getting these errors? I tried reinstalling node but that doesnt seem to fix it. Thanks for the help in advance, keep in mind i am completely new to react native
Assuming that you have Node 10 LTS or greater installed, you can use npm to install the Expo CLI command line utility:
npm install -g expo-cli
expo init AwesomeProject
cd AwesomeProject
npm start # you can also use: expo start

Failed at the #angular/cli#8.3.19 postinstall script

Hi I can't install the angular cli with npm install -g #angular/cli#8.3.19.
I keep getting this :
> node ./bin/postinstall/script.js
module.js:549
throw err;
^
Error: Cannot find module '/root/.nvm/versions/node/v13.0.1/lib/node_modules/#angular/cli/bin/postinstall/script.js'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Function.Module.runMain (module.js:693:10)
at startup (bootstrap_node.js:188:16)
at bootstrap_node.js:609:3
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! #angular/cli#8.3.19 postinstall: `node ./bin/postinstall/script.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the #angular/cli#8.3.19 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2019-11-26T00_10_33_515Z-debug.log
Node version : 13.0.1
Npm version : 6.13.1
Ubuntu version : 18.04.2
I also tried without specifying a CLI version.
I tried with this command that I found online :
npm install -g #angular/cli#8.3 --unsafe-perm=true --allow-root
And it worked.
Try to run with sudo npm. On Ubuntu, you need to run with root permission. It depends on how you install node.
sudo npm install -g #angular/cli#8.3.19
On the other hand, try to install node 12 and LTS versions to have a more secure version.
Hope it helps
Try clean your npm cache before npm cache clean or npm cache verify then npm install -g #angular/cli#8.3 --unsafe-perm=true --allow-root
Steps I followed
Downgrade node version using nvm to v12.3.0
Remove ng folder from /root/.nvm/versions/node/v12.3.0/bin
Again do npm install -g #angular/cli#8.3 --unsafe-perm=true --allow-root
and it worked

Can't install any Node packages globally Ubuntu Digital Ocean

Tried everything. Tried all the steps below, didn't work so I nuked my droplet and rebuilt to start over and try again. I'm Using Ubuntu. First thing once I ssh into my droplet was install node and npm via:
https://nodejs.org/en/download/package-manager/
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
Then
npm -v
5.6.0
node -v
v8.11.3
Then I try to install a package globally. I tried electron and it failed so I began messing with the node modules folder as I was getting the permission error with the fix documented here:
https://askubuntu.com/questions/869168/node-modules-have-755-permissions-what-permissions-should-i-set-so-that-npm-don
No luck. So I tried the solution documented here:
NPM global install "cannot find module"
echo $NODE_PATH
/usr/lib/nodejs:/usr/lib/node_modules:/usr/share/javascript:/home/username/.npm-global/lib/node_modules
So that didn't work either. This is the error now when I try and install any package globally:
npm install -g electron
I get:
Error: Cannot find module '/root/.npm-global/lib/node_modules/nightmare/node_modules/electron/install.js'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Function.Module.runMain (module.js:693:10)
at startup (bootstrap_node.js:191:16)
at bootstrap_node.js:612:3
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! electron#1.8.7 postinstall: `node install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the electron#1.8.7 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2018-08-03T03_26_03_827Z-debug.log
This error for any package I try to install. Not sure what else to try. Don't want to wipe out the droplet and start over...
I also had this issue but after adding sudo at start the issue went away.
like:
sudo npm -g install nodemon

NPM permission error while installing

i am trying to install yeoman on my server but for some reason do i keep getting a permission denied error.
$npm install -g yo
/root/.node/bin/yo -> /root/.node/lib/node_modules/yo/cli.js
> yo#1.3.3 postinstall /root/.node/lib/node_modules/yo
> yodoctor
sh: 1: yodoctor: Permission denied
npm ERR! yo#1.3.3 postinstall: `yodoctor`
npm ERR! Exit status 127
npm ERR!
npm ERR! Failed at the yo#1.3.3 postinstall script.
npm ERR! This is most likely a problem with the yo package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! yodoctor
npm ERR! You can get their info via:
npm ERR! npm owner ls yo
npm ERR! There is likely additional logging output above.
npm ERR! System Linux 3.13.0-37-generic
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install" "-g" "yo"
npm ERR! cwd /root
npm ERR! node -v v0.10.33
npm ERR! npm -v 1.4.28
npm ERR! code ELIFECYCLE
npm ERR! not ok code 0
i have tried to reinstall ubuntu (14.04) but nothing works.
I think Shantaru is right, you need to do it with sudo.
Try this
sudo npm uninstall -g yo
sudo npm cache clean
sudo npm install -g yo
I have a similar problem weeks ago and that works.
Edit: If that didn't work, do this before:
npm config set unsafe-perm true
You need to have root permission to install this so try
"sudo npm install -g yo" instead of "npm install -g yo"
I had the same issue and tried running the install using 'sudo npm install -g yo' but it still failed. I couldn't get away from the fact that the error message still said 'sh: 1: yodoctor: Permission denied', indicating a permissions issue. I therefore tried completely changing to the root user using 'sudo su' and THEN running 'npm install -g yo'. This worked for me.
If, like me, when running the install that way you encounter other errors, it could be because you need to upgrade npm first (run 'npm install -g npm' to do that). It could also be because you have yo partially installed from your previous attempts and that's causing issues. Therefore you can try removing it first using 'npm remove -g yo' (still as root user) and then installing it again using 'npm install -g yo'.
Hope this helps someone out there.
To avoid permission errors, install node with nvm.
See the detailed solution here:
npm install g less does not work

Trouble installing tower module - ws module crashes

I'm new to node.js and I have installed it by running the installation from the node website. I've had a play installing packages globally (e.g. should) but now I'm trying to install the tower module on my Mac, like so:
sudo npm install tower -g
It install a bunch of stuff and then crashes, with output
npm http 304 https://registry.npmjs.org/tinycolor
npm http 304 https://registry.npmjs.org/zeparser/0.0.5
> ws#0.4.20 install /usr/local/lib/node_modules/tower/node_modules/socket.io/node_modules/socket.io-client/node_modules/ws
> node install.js
shell-init: error retrieving current directory: getcwd: cannot access parent directories: Permission denied
node.js:520
var cwd = process.cwd();
^
Error: EACCES, permission denied
at Function.startup.resolveArgv0 (node.js:520:23)
at startup (node.js:54:13)
at node.js:611:3
npm ERR! ws#0.4.20 install: `node install.js`
npm ERR! `sh "-c" "node install.js"` failed with 11
npm ERR!
npm ERR! Failed at the ws#0.4.20 install script.
npm ERR! This is most likely a problem with the ws package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node install.js
npm ERR! You can get their info via:
npm ERR! npm owner ls ws
npm ERR! There is likely additional logging output above.
If I read that correctly it's the ws (websockets?) module crashing.
In researching this problem a blog suggested I add the node path to my .bashrc so I have done that.
Any suggestions?
At this line:
ws#0.4.20 install /usr/local/lib/node_modules/tower/node_modules/socket.io/node_modules/socket.io-client/node_modules/ws
We see that ws is install in /usr/local/lib, I need root to write here no ?
I'm using linux, it's maybe not the case in mac...
You should use sudo npm install -g tower or install Node.js with nvm. Nvm cares that modules are install in your home, so you do not need sudo.
After much experimentation the only thing that worked for me was to enable the OSX root account, and then:
su
npm install -g tower
sudo did not work but su did.

Resources