Error when installing the express application generator - express

I recently installed node and express with the help of the mozilla tutorial. I am on the next step of installing the application generator, but when I run
npm install express-generator -g
in my terminal: I recieve the following errors:
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! Please try running this command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/adamgusky/.npm/_logs/2018-02-17T20_26_53_688Z-debug.log
I've been googling this topic for an hour now and I am very new to using the terminal for web applications (this is for a school project), so any help is appreciated.

I had a similar issue. The problem is that you aren't an administrator so you can't write to that folder. However it's considered a BAD IDEA to run sudo npm install. So what you need to do is to change the default install folder for npm global installation to one where you do have write permission.
See npm's documentation: https://docs.npmjs.com/getting-started/fixing-npm-permissions.
And also see this useful article on github: https://github.com/nodeschool/discussions/wiki/Installing-global-node-modules-(Linux-and-Mac)

Related

Getting No such file or directory: 'ganache-cli' error

I installed ganache-cli using npm install -g ganache-cli, however I am running into a No such file or directory: 'ganache-cli error when trying to run it. When calling echo $PATH, I see ~/.npm-global/bin, which contains the ganache-cli file, so I am confused as to what the issue could be. Any help is greatly appreciated.
For reference, I am using zsh on MacOS.
ganache-cli is now deprecated. You might see the following npm-warning:
npm WARN deprecated ganache-cli#6.12.2: ganache-cli is now ganache; visit https://trfl.io/g7 for details
Use npm install -g ganache.
Use sudo npm install -g ganache if you get some error like this:
$ npm install -g ganache
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib/node_modules
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.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/ubuntu/.npm/_logs/2022-06-23T12_37_16_476Z-debug.log

How to install expo cli correctly?

I am trying to install expo cli globally but I am getting errors:
OS: Catalina 10.15.4
Node: 14.6
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib/node_modules
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.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/mac/.npm/_logs/2020-07-25T10_36_46_119Z-debug.log
I install in the Visual Studio terminal, I also tried to install through the console, but the result did not change
When installing some packages globally, you need to do so as a privileged user. On Mac, use sudo to elevate the installation command. E.g. sudo npm install your-package -g

Error when trying to run "npm i -g http-server" on Mac

I am a total beginner when it comes to programming and have no clue what I am doing. I am doing a course called Your last Intro to Programming Course on Udemy for a local coding bootcamp and I am only in the setup stage and already ran into this issue. I followed every instruction exactly and there is no comments or information on the course to help me figure it out. Please help? (I am on a Mac with the latest software.)
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib/node_modules
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 would check the permissions on the directory /usr/local/lib/node_modules using ls -l /usr/local/lib/node_modules to make sure it is not owned by root. If it is, I would run sudo chown -R <not root account>

Missing write access when installing Vue CLI

For some reason I cannot run the vue cli and trying to reinstall using:
npm install -g #vue/cli
I get a string of
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/#vue/cli/node_modules/#apollographql/graphql-playground-html
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/#vue/cli/node_modules/#babel/core/node_modules/semver
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/#vue/cli/node_modules/#babel/helper-plugin-utils
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/#vue/cli/node_modules/#babel/parser
And then ending with
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib/node_modules/#vue/cli/node_modules/#apollographql/graphql-playground-html
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules/#vue/cli/node_modules/#apollographql/graphql-playground-html'
npm ERR! { Error: EACCES: permission denied, access '/usr/local/lib/node_modules/#vue/cli/node_modules/#apollographql/graphql-playground-html'
npm ERR! stack: 'Error: EACCES: permission denied, access \'/usr/local/lib/node_modules/#vue/cli/node_modules/#apollographql/graphql-playground-html\'',
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/local/lib/node_modules/#vue/cli/node_modules/#apollographql/graphql-playground-html' }
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 have tried changing the permissions of /usr/local/lib/node_modules and then changed the group to "staff" (which is the same as Python also in /lib. I don't think I can uninstall node without some serious problems everywhere I use that. Stuck and not sure how to install or get vue cli running.
I have just had the same issue, but solved it by adding "sudo" before it.
So, the new line would instead look like;
sudo npm install -g #vue/cli

I couldn't install npm on my mac. I got the following errors

I am getting following checkPermissions error related write access while doing npm install.
npm install
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/npm/node_modules/tar/node_modules/minizlib
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/npm
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/npm/node_modules/tar/node_modules
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! path /usr/local/lib/node_modules/npm/node_modules/tar/node_modules/minizlib
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/node_modules/tar/node_modules/minizlib'
npm ERR! { Error: EACCES: permission denied, access '/usr/local/lib/node_modules/npm/node_modules/tar/node_modules/minizlib'
npm ERR! stack: 'Error: EACCES: permission denied, access \'/usr/local/lib/node_modules/npm/node_modules/tar/node_modules/minizlib\'',
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/local/lib/node_modules/npm/node_modules/tar/node_modules/minizlib' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/mac/.npm/_logs/2018-02-08T17_10_28_286Z-debug.log .
Please provide some reference or information.
Use sudo in front of your install command and enter your password when prompted. It installs NPM into the global space, which requires SUDO if you are not on the root account.
That is what this part of the error is telling you: "Please try running this command again as root/Administrator."
After you install npm, you will have issues with global packages.
Use this suggested way of resolving it. Better, secure & maintainable.
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
nano ~/.zprofile
# Add a line to add the new dir to path, eg:
# PATH="~/.npm-global/bin":$PATH
# export PATH
source ~/.zprofile
Ref: https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally