i can not install nodemon it has problem with npm
Vus-MacBook-Air:nodejs vuvantuu$ sudo npm install -g nodemon
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/nodemon
npm ERR! path /usr/local/lib/node_modules/nodemon
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall access
npm ERR! enoent ENOENT: no such file or directory, access '/usr/local/lib/node_modules/nodemon'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/vuvantuu/.npm/_logs/2019-08-08T07_07_43_043Z-debug.log
You must be required administrative privileges to install anything,
you can use
sudo npm install -g nodemon
As the error says - you don't have write access to the /usr/local/lib/node_modules folder.
The simplest way to get rid of this error - is to run the command via sudo
sudo npm i -g nodemon
But if you don't want to run it via root user for any reasons (e.g security) you could install packages globally for a given user.
Create a directory for global packages
mkdir "${HOME}/.npm-packages"
Tell npm where to store globally installed packages
npm config set prefix "${HOME}/.npm-packages"
Ensure npm will find installed binaries and man pages
Add the following to your .bashrc/.zshrc:
NPM_PACKAGES="${HOME}/.npm-packages"
export PATH="$NPM_PACKAGES/bin:$PATH"
# Unset manpath so we can inherit from /etc/manpath via the `manpath` command
unset MANPATH # delete if you already modified MANPATH elsewhere in your config
export MANPATH="$NPM_PACKAGES/share/man:$(manpath)"
NOTE: If you are running macOS, the .bashrc file may not yet exist, and the terminal will be obtaining its environment parameters from another file, such as .profile or .bash_profile. These files also reside in the user's home folder. In this case, simply adding the following line to them will instruct Terminal to also load the .bashrc file:
source ~/.bashrc
Related
I get response, When try to write:
$ /opt/cpanel/ea-nodejs16/bin/npm -v
8.1.2
but with :
$ npm -v
bash: npm: command not found
So, I tried as the same logic but it didn't work:
$ /opt/cpanel/ea-nodejs16/bin/npm install
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /home/mydomain/public_html/app/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/home/mydomain/public_html/app/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /home/mydomain/.npm/_logs/2022-03-02T14_43_55_155Z-debug.log
So, how to make " npm " command lines works on server.
First install NodeJS install on cPanel, WHM.
To install NodeJS from WHM, Goto Home /
Software /
EasyApache 4
And in Additional Packages find NodeJS.
After that create an environment variable which points to the node directory.
Run this command to do that.
export PATH=/opt/cpanel/ea-nodejs16/bin/:$PATH
Finally run npm -v to check NodeJS version.
Hope this will help for someone.
You need to create an environment variable which points to the right directory. This should do the job:
export PATH=/opt/cpanel/ea-nodejs16/bin/:$PATH
or add it to your .bashrc file to keep it persistent. And regarding this npm error you get, as jordanm mentioned you don't have package.json file in you current directory.
You have to store the path inside in your .bashrc file. You can do it easily by run following command.
echo export PATH=/opt/cpanel/ea-nodejs16/bin/:$PATH
I am having trouble using grunt in my projects. I am setting up an macos computer with version 11.0.1.
The project files (local) are in principle correct, since I use it on another computer and it works fine there.
I have been trying to solve this error for more than two days, the problem is that the local configuration does not work correctly, since I get the message ~ bash: grunt command not found when trying to initialize grunt with the grunt or grunt watch command
When trying to install grunt-cli globally I get this error:
npm ERR! code ENOENT
npm ERR! syscall lstat
npm ERR! path /Users/bertanicolau/.npm-packages
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, lstat '/Users/bertanicolau/.npm-packages'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/bertanicolau/.npm/_logs/2020-11-23T17_06_23_295Z-debug.log
The .npm-packages folder does not exist in this location, instead the .npm folder does exist, I don't know why it is looking for another.
I've tried clearing the npm cache, I've also tried deleting the package-lock.json file and changing paths on .bash-profile but none of this seems to work.
Can it be a npm or node version bug?
$ npm -v && node -v
7.0.8
v15.2.1
Thanks!
In one of your .npmrc files, you probably have prefix=/Users/trott/.npm-packages. If so, leave it and create the directory with mkdir ~/.npm-packages. Or set it to a different directory. Or remove the entry entirely.
The places to look for the .npmrc file that may be causing this to happen:
per-project config file (/path/to/my/project/.npmrc)
per-user config file (~/.npmrc)
global config file ($PREFIX/etc/npmrc)
npm builtin config file (/path/to/npm/npmrc)
Hello i have this error if i try to install electron on my fedora 30
[luisjustin#localhost ~]$ sudo su
[sudo] password for luisjustin:
[root#localhost luisjustin]# npm install -g electron
/usr/bin/electron -> /usr/lib/node_modules/electron/cli.js
> electron#5.0.2 postinstall /usr/lib/node_modules/electron
> node install.js
/usr/lib/node_modules/electron/install.js:49
throw err
^
Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/electron/.electron'
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! electron#5.0.2 postinstall: `node install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the electron#5.0.2 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-05-30T01_21_04_805Z-debug.log
[root#localhost luisjustin]#
the log in this link: https://pastebin.com/q3dSCQVg
There seems to be an issue with permissions on your machine (/usr/lib directory requires root access). What I suggest you to try is to change the default directory where NPM is installing packages globally. Then you can try to run the installation without root access.
Try this:
On the command line, in your home directory, create a directory for global installations:
mkdir ~/.npm-global
Configure npm to use the new directory path:
npm config set prefix '~/.npm-global'
In your preferred text editor, open or create a ~/.profile file and add this line:
export PATH=~/.npm-global/bin:$PATH
On the command line, update your system variables:
source ~/.profile
To test your new configuration, install a package globally without using sudo:
npm install -g electron
Courtesy:
https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally
I've been attempting to install a npm package, which has been throwing a bunch of errors which I'm not too familiar with. Keep in mind that these errors are after executing sudo npm install -g skpm:
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/skpm/node_modules/keytar/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" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/skpm/node_modules/keytar
gyp ERR! node -v v8.9.1
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! keytar#4.1.0 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the keytar#4.1.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! /Users/USERNAME/.npm/_logs/2017-12-19T01_53_44_910Z-debug.log
Originally I'd thought that I needed to install keytar to make this work, but after installing I still had the same errors.
Avoid use sudo npm -g install
During gyp compilation you will have such problems again and again.
Fixing permissions is the solution.
Quote from npm docs:
You can fix this problem using one of three options:
Change the permission to npm's default directory.
Change npm's default directory to another directory.
Install Node with a package manager that takes care of this for you. You should back-up your computer before moving forward.
Option 1: Change the permission to npm's default directory
Find the path to npm's directory: npm config get prefix For many systems, this will be /usr/local.
WARNING: If the displayed path is just /usr, switch to Option 2 or you
will mess up your permissions.
Change the owner of npm's directories to the name of the current user
(your username!):
sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}
This changes the permissions of the sub-folders used by npm and some other tools (lib/node_modules, bin, and share).
Option 2: Change npm's default directory to another directory
There are times when you do not want to change ownership of the
default directory that npm uses (i.e. /usr) as this could cause some
problems, for example if you are sharing the system with other users.
Instead, you can configure npm to use a different directory
altogether. In our case, this will be a hidden directory in our home
folder.
Make a directory for global installations:
mkdir ~/.npm-global
Configure npm to use the new directory path:
npm config set prefix '~/.npm-global'
Open or create a ~/.profile file and add this line:
export PATH=~/.npm-global/bin:$PATH
Back on the command line, update your system variables:
source ~/.profile
Test: Download a package globally without using sudo.
npm install -g jshint
Instead of steps 2-4, you can use the corresponding ENV variable (e.g. if you don't want to modify ~/.profile):
NPM_CONFIG_PREFIX=~/.npm-global
Option 3: Use a package manager that takes care of this for you.
If you're doing a fresh install of Node on Mac OS, you can avoid this
problem altogether by using the Homebrew package manager. Homebrew
sets things up out of the box with the correct permissions.
brew install node
usually EACCES: permission denied occurs trying to install a package globally (with -g) without providing permissions. Supposing that you are on os with sudo, try call
sudo npm install -g skpm
or, if you don't want it global
npm install skpm
I found the issue as to why skpm was not installing.
Make sure you install x-code + command line tools access
This fixed the issue and SKPM installed.
I am trying to set up a chrome extension that will automatically save the changes I make to my website with the inspect element feature. The idea is that you'll be able to make real time changes to the website without having to go back into the ide to save the changes and re-upload and everything. The extension is called DevTools Autosave. I've been following the instructions from this site. I'm trying to install this on a mac.
I've installed node.js and the extension already. When I got to the part in the instructions where it talks about which commands to run in the terminal I've tried both with and without the "sudo" in front of the "npm install -g autosave" command but I always get this error:
Error: EACCES, permission denied
at Function.startup.resolveArgv0 (node.js:815:23)
at startup (node.js:58:13)
at node.js:906:3
npm ERR! autosave#1.0.3 install: `node ./scripts/install.js`
npm ERR! Exit status 8
npm ERR!
npm ERR! Failed at the autosave#1.0.3 install script.
npm ERR! This is most likely a problem with the autosave package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node ./scripts/install.js
npm ERR! You can get their info via:
npm ERR! npm owner ls autosave
npm ERR! There is likely additional logging output above.
npm ERR! System Darwin 14.0.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "-g" "autosave"
npm ERR! cwd /Users/Brent
npm ERR! node -v v0.10.33
npm ERR! npm -v 1.4.28
npm ERR! code ELIFECYCLE
npm ERR! not ok code 0
Anyone know how I can fix this? I can't find anyone that is having this problem and I've been on a few different forums now but can't find a solution. Thanks in advance.
You have two options: Either fix your npm setup, so you can use npm -g, or install autosave locally.
To install locally (i.e. in node_modules within your current directory), run npm install autosave (without -g). Then you can run ./node_modules/.bin/autosave or ./node_modules/autosave/bin/autosave to start autosave.
To fix your npm setup, so you can use -g without root permissions (recommended):
In your home dir (assuming /Users/Brent/), create a file called .npmrc with the following content:
cache = /Users/Brent/.npm/cache
globalconfig = /Users/Brent/.npm/npmrc
globalignorefile = /Users/Brent/.npm/npmignore
prefix = /Users/Brent/.npm
And add ~/.npm/lib/node_modules to your NODE_PATH, e.g. by putting the following in .bashrc (assuming that your shell is bash) to allow the modules to be found, and append ~/.npm/bintoPATHso you can run any installed binary (i.e. runautosave` from anywhere):
export NODE_PATH=$HOME/.npm/lib/node_modules
export PATH=$PATH:$HOME/.npm/bin
(changes to .bashrc only take effect when you load the shell, or use . ~/.bashrc; if you want to use the new setup without reloading the shell, just run that line (export ...) in your current shell).
As of 2020, here is the recommended solution by npm. It worked for me (OSX). (No need to change any path configuration or .bashrc)
Steps:
Install nvm by running below command.
If you are using bash
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh | bash
If you are using zsh
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh | zsh
Install node using nvm (No need to uninstall existing node/npm)
nvm install 12.13.1