Installing Angular on Mac OS 10.13 - node.js

I'm trying to follow the quickstart on running Angular locally (on MacOS 10.13.6). With the first command, I already get some errors:
npm install -g #angular/cli
Output:
npm ERR! path /usr/local/lib/node_modules/#angular/cli/node_modules/socks
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules/#angular/cli/node_modules/socks'
npm ERR! { [Error: EACCES: permission denied, access '/usr/local/lib/node_modules/#angular/cli/node_modules/socks']
npm ERR! stack:
npm ERR! 'Error: EACCES: permission denied, access \'/usr/local/lib/node_modules/#angular/cli/node_modules/socks\'',
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path:
npm ERR! '/usr/local/lib/node_modules/#angular/cli/node_modules/socks' }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator (though this is not recommended).
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/xxx/.npm/_logs/2019-03-12T23_55_12_063Z-debug.log
Running with sudo gives me the following:
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/#angular/cli/node_modules/fsevents/.node-gyp'
gyp ERR! System Darwin 17.7.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/usr/local/lib/node_modules/#angular/cli/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64/fse.node" "--module_name=fse" "--module_path=/usr/local/lib/node_modules/#angular/cli/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64" "--napi_version=3" "--node_abi_napi=napi"
gyp ERR! cwd /usr/local/lib/node_modules/#angular/cli/node_modules/fsevents
gyp ERR! node -v v10.15.3
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/usr/local/lib/node_modules/#angular/cli/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64/fse.node --module_name=fse --module_path=/usr/local/lib/node_modules/#angular/cli/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64 --napi_version=3 --node_abi_napi=napi' (1)
node-pre-gyp ERR! stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/#angular/cli/node_modules/fsevents/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:189:13)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:970:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
node-pre-gyp ERR! System Darwin 17.7.0
node-pre-gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/#angular/cli/node_modules/fsevents/node_modules/node-pre-gyp/bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /usr/local/lib/node_modules/#angular/cli/node_modules/fsevents
node-pre-gyp ERR! node -v v10.15.3
node-pre-gyp ERR! node-pre-gyp -v v0.10.3
node-pre-gyp ERR! not ok
Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/usr/local/lib/node_modules/#angular/cli/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64/fse.node --module_name=fse --module_path=/usr/local/lib/node_modules/#angular/cli/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64 --napi_version=3 --node_abi_napi=napi' (1)
My node version is LTS (10.15.3). Any idea what's causing this and how to get angular to run on Mac?

you will need the write permission in node_modules directory:
sudo chown -R $(whoami) ~/.npm
Running sudo when installing npm will give you problems in the long run, so just run the command above.
npm throws error without sudo

sudo npm install -g #angular/cli
run with sudo permission and you should be good.

the /usr/local folder needs root permission, please try install it with sudo :
sudo npm install -g #angular/cli

As mentioned in the comments, using sudo isn't good practice, I had to run the following 3 commands to gain ownership of the relevant directories:
sudo chown -R $(whoami) ~/.npm
sudo chown -R $(whoami) /usr/local/lib/node_modules
sudo chown -R $(whoami) /usr/local/bin
Now I can install Angular CLI (or any other node packages) globally, without the need for sudo.

Related

live-server won't be installed globally on Mac BigSur

My fresh new Mac Air won't install live-server globally. It keeps throwing the same error after I factory reseted my Mac though.
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR! [Error: EACCES: permission denied, access '/usr/local/lib/node_modules'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/local/lib/node_modules'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
I tried re-install again on root but it throws this error
gyp WARN EACCES current user ("nobody") does not have permission to access the dev dir "/var/root/Library/Caches/node-gyp/14.17.0"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/live-server/node_modules/fsevents/.node-gyp"
gyp WARN install got an error, rolling back install
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/live-server/node_modules/fsevents/.node-gyp'
gyp ERR! System Darwin 20.5.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/live-server/node_modules/fsevents
gyp ERR! node -v v14.17.0
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
+ live-server#1.2.1
How do I actually install live-server on my Mac globally?
It looks like the error is caused because the script doesn't have the permissions to access /var.
Have you tried installing with sudo?
sudo npm install -g live-server

I want to install mechanic on npm, I tried to run this line sudo npm install -g mechanic, but it gives me error, I don't understand this error

I want to install mechanic on my nginx server.
I got this error when I execute sudo npm install -g mechanic:
tigaron#galaxybrainpower:/var/www/tigaron$ sudo npm install -g mechanic
/usr/bin/mechanic -> /usr/lib/node_modules/mechanic/bin/mechanic
> fs-ext#2.0.0 install /usr/lib/node_modules/mechanic/node_modules/fs-ext
> node-gyp configure build
gyp WARN EACCES current user ("nobody") does not have permission to access the dev dir "/home/tigaron/.cache/node-gyp/10.20.1"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/lib/node_modules/mechanic/node_modules/fs-ext/.node-gyp"
gyp WARN install got an error, rolling back install
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/mechanic/node_modules/fs-ext/.node-gyp'
gyp ERR! System Linux 4.15.0
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "build"
gyp ERR! cwd /usr/lib/node_modules/mechanic/node_modules/fs-ext
gyp ERR! node -v v10.20.1
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! fs-ext#2.0.0 install: `node-gyp configure build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the fs-ext#2.0.0 install 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! /home/tigaron/.npm/_logs/2020-05-24T06_29_26_857Z-debug.log
What is happening here? How to fix this error and proceed with the installation?
This answer solved the same issue I had when installing a different package.
Apparently the nobody user is used when building packages globally, but the directories are owned by root so it fails permissions. Configuring npm to use root with the following command is what the answer recommends.
npm -g config set user root

running problems when trying to install hdf5 package using npm

hdf5#0.3.3 install /usr/local/lib/node_modules/hdf5
node-gyp rebuild --jobs max
gyp ERR! configure error gyp ERR! stack Error: EACCES: permission
denied, mkdir '/usr/local/lib/node_modules/hdf5/build' gyp ERR! System
Darwin 17.7.0 gyp ERR! command "/usr/local/bin/node"
"/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js"
"rebuild" "--jobs" "max" gyp ERR! cwd /usr/local/lib/node_modules/hdf5
gyp ERR! node -v v8.11.3 gyp ERR! node-gyp -v v3.6.2 gyp ERR! not ok
npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! hdf5#0.3.3 install:
node-gyp rebuild --jobs max npm ERR! Exit status 1 npm ERR! npm ERR!
Failed at the hdf5#0.3.3 install 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!
/Users/abc/.npm/_logs/2018-07-20T21_24_19_576Z-debug.log
Your error clearly says: Error: EACCES: permission denied, mkdir which is a permissions issue. Looks likes it trying to create directory called build inside /usr/local/lib/node_modules/hdf5/.
To fix it, just run the same command with sudo at the beginning.
But, I would not recommend it unless you install global package.
Do you try to install a local package ? if so, make sure the permissions of the node_modules is not root. If it does, either chown it or remove it and do npm install with non-root user.

firebase-tools fails to load via terminal install on macOS

Trying to install firebase-tool for CLI. Getting failures.
running on macOS
I have seen suggestions like the following ...
Troubling with installing firebase-tools
I tried $ sudo npm install -g firebase-tools
Using 'sudo' gets past the error issues trying to access directories. but still crashes
The troubling bit seems to be this
node-pre-gyp ERR! Tried to download(undefined): https://storage.googleapis.com/grpc-precompiled-binaries/node/grpc/v1.4.1/node-v57-darwin-x64.tar.gz
I can put the above URL in a browser and it will download the tar.
I also have access problem even if I use 'sudo'
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/firebase-tools/node_modules/grpc/build'
Trying to understand how to get past the errors to install firebase-tools, Also some suggestions say to install node via nvm. Found tutorial on nvm, anyone know what doing this install will to to projects I already have on my machine. e.g confusion finding correct node.js, or need to reinstall everything that I already installed using my current node install?
The full error messages are ...
sudo npm install -g firebase-tools
Password:
npm WARN deprecated node-uuid#1.4.8: Use uuid module instead
/usr/local/bin/firebase -> /usr/local/lib/node_modules/firebase- tools/bin/firebase
> grpc#1.4.1 install /usr/local/lib/node_modules/firebase- tools/node_modules/grpc
> node-pre-gyp install --fallback-to-build --library=static_library
node-pre-gyp ERR! Tried to download(undefined): https://storage.googleapis.com/grpc-precompiled-binaries/node/grpc/v1.4.1/node- v57-darwin-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for grpc#1.4.1 and node#8.9.4 (node-v57 ABI) (falling back to source compile with node-gyp)
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/firebase-tools/node_modules/grpc/build'
gyp ERR! System Darwin 17.3.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--library=static_library" "-- module=/usr/local/lib/node_modules/firebase- tools/node_modules/grpc/src/node/extension_binary/grpc_node.node" "-- module_name=grpc_node" "--module_path=/usr/local/lib/node_modules/firebase-tools/node_modules/grpc/src/node/extension_binary"
gyp ERR! cwd /usr/local/lib/node_modules/firebase-tools/node_modules/grpc
gyp ERR! node -v v8.9.4
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --library=static_library -- module=/usr/local/lib/node_modules/firebase- tools/node_modules/grpc/src/node/extension_binary/grpc_node.node -- module_name=grpc_node --module_path=/usr/local/lib/node_modules/firebase- tools/node_modules/grpc/src/node/extension_binary' (1)
node-pre-gyp ERR! stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/firebase-tools/node_modules/grpc/node_modules/node- pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack at emitTwo (events.js:126:13)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:214:7)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:925:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
node-pre-gyp ERR! System Darwin 17.3.0
node-pre-gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/firebase- tools/node_modules/grpc/node_modules/.bin/node-pre-gyp" "install" "--fallback- to-build" "--library=static_library"
node-pre-gyp ERR! cwd /usr/local/lib/node_modules/firebase- tools/node_modules/grpc
node-pre-gyp ERR! node -v v8.9.4
node-pre-gyp ERR! node-pre-gyp -v v0.6.36
node-pre-gyp ERR! not ok
Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --library=static_library -- module=/usr/local/lib/node_modules/firebase- tools/node_modules/grpc/src/node/extension_binary/grpc_node.node -- module_name=grpc_node --module_path=/usr/local/lib/node_modules/firebase- tools/node_modules/grpc/src/node/extension_binary' (1)
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: grpc#1.4.1 (node_modules/firebase-tools/node_modules/grpc):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: grpc#1.4.1 install: `node- pre-gyp install --fallback-to-build --library=static_library`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1
+ firebase-tools#3.17.4
added 8 packages and updated 1 package in 37.194s
I also tried to cd in to the node_modules directory and run the install from there as proposed in this post
firebase-tools cannot install, why?
The result is pages and pages of warning messages and finally an error
npm ERR! path /usr/local/lib/node_modules/firebase-tools/bin/firebase
npm ERR! code ELOOP
npm ERR! errno -62
npm ERR! syscall chmod
npm ERR! ELOOP: too many symbolic links encountered, chmod '/usr/local/lib/node_modules/firebase-tools/bin/firebase'
npm install -g firebase-tools
works on windows without causing any error. but when it comes to Mac you need to start it with sudo.
so the command will be:
sudo npm install -g firebase-tools
then check the version using firebase -V on terminal to make sure you've done correctly.
I encountered the same problem what I did was made sure I was in root directory and the ran :
sudo npm i g firebase-tools
Or in Windows
npm i g firebase-tools
I was constantly doing it in my project folder and kept getting the same error.
I had the same problem on macOS High Sierra. The only thing that worked for me in the end was to uninstall node.js from Homebrew (brew uninstall node), then install node.js using the downloadable installer (https://nodejs.org/en/download/) then install the Firebase CLI using sudo:
sudo npm install -g firebase-tools
After that, I still received the warnings, but could launch and configure Firebase. Not an ideal solution, but it is serving as a fix for me at the moment.
sudo npm install -g firebase-tools
sudo worked for me!
Without sudo I was getting the following error:
Lewis-MacBook-Pro:demo-firebase-func leg$ npm install -g firebase-tools
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! path /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR! { Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR! stack: 'Error: EACCES: permission denied, access \'/usr/local/lib/node_modules\'',
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/local/lib/node_modules' }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator (though this is not recommended).
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/leg/.npm/_logs/2018-10-03T20_35_51_209Z-debug.log
Installing Node from the package on its website, rather than through Brew, solved this issue for me.
In my case I had a corrupted Firebase install, solved by running:
curl -sL firebase.tools | upgrade=true bash
If you don't have Firebase already you can just run:
curl -sL firebase.tools
Reference: https://firebase.google.com/docs/cli#mac-linux-auto-script

Meteor Error: EACCES: permission denied, rmdir 'build'

I have this error when i try to update my meteor project from Meteor 1.3.5.1 to METEOR 1.4. I don't know why i have this error. I have already try to do a chown to .meteor and .np floder.
=> Errors while initializing project:
While loading package npm-bcrypt#0.8.7:
error: Command failed:
/home/noob/.meteor/packages/meteor-tool/.1.4.0.hylsrj++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/bin/npm
rebuild --no-bin-links --update-binary
gyp ERR! clean error
gyp ERR! stack Error: EACCES: permission denied, rmdir 'build'
gyp ERR! stack at Error (native)
gyp ERR! System Linux 3.16.0-38-generic
gyp ERR! command
"/home/noob/.meteor/packages/meteor-tool/.1.4.0.hylsrj++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/bin/node"
"/home/noob/.meteor/packages/meteor-tool/.1.4.0.hylsrj++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js"
"rebuild"
gyp ERR! cwd
/home/noob/.meteor/packages/npm-bcrypt/.0.8.7.1np1i1l++os.linux.x86_64+web.browser+web.cordova/npm/node_modules/.temp-140iag7/node_modules/bcrypt
gyp ERR! node -v v4.4.7
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
npm ERR! Linux 3.16.0-38-generic
npm ERR! argv
"/home/noob/.meteor/packages/meteor-tool/.1.4.0.hylsrj++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/bin/node"
"/home/noob/.meteor/packages/meteor-tool/.1.4.0.hylsrj++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/bin/npm"
"rebuild" "--no-bin-links" "--update-binary"
npm ERR! node v4.4.7
npm ERR! npm v3.10.5
npm ERR! code ELIFECYCLE
npm ERR! bcrypt#0.8.7 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
.....
It was an permission error
I do a sudo chown -R $USERNAME /home/noob and now all work fine
Look more like a Node-gyp problem.
Extracted from Meteor docs:
If you have binary npm packages in your application node_modules
directory, you should run meteor npm rebuild (after meteor update) in
your application directory to recompile those packages.
If it still doesn't work, try removing your ~/.node-gyp file and then npm update.
Had to delete bcrypt directory
rm -r $HOME/.meteor/packages/npm-bcrypt/.0.7.8_2.f294j7++os.osx.x86_64+web.browser+web.cordova/npm/node_modules/bcrypt

Resources