1

I've installed fkill globally by doing npm i -g fkill. I can see it installed when I do npm list. It shows only fkill as installed globally when I run npm list -g --depth=0. However when I run fkill I get "command not found".

Next I ran "npm get prefix" and got "/home/alex/.node_modules". Here is my PATH:

/home/alex/.node_modules/bin:/home/alex/.npm-global/bin:/home/alex/.node_modules/bin:/home/alex/.node_modules/lib/node_modules:/home/alex/.local/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/opt/cuda/bin:/var/lib/flatpak/exports/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/var/lib/snapd/snap/bin

This all began after I tried to run system updates with pacman and got node conflicts, so I uninstalled node and ran my updates, then reinstalled node.

Any ideas?

This is on Manjaro.

5
  • Try to add /usr/local/share/npm/bin to your PATH in .bashrc. – harrymc Mar 13 '20 at 18:25
  • No good. Tried adding it to bashrc, ~/.profile, ~/.bash_profile. I tried adding both export PATH=$PATH:/usr/local/share/npm/bin and PATH=$PATH:/usr/local/share/npm/bin to all of those files. Still can't run npm packages. – aboutros Mar 13 '20 at 19:06
  • There are (too) many posts to be found for this problem. Try for example this post. – harrymc Mar 13 '20 at 19:17
  • Well I went through all the solutions there and nothing worked, so I gave up and reinstalled Manjaro (was a relatively fresh install anyways). Same problem, but this time when I did the steps here: (which is an answer on this page, for some reason it worked this time. – aboutros Mar 14 '20 at 1:23
  • Glad that the problem was resolved. I put in an answer below the method that worked for you. – harrymc Mar 14 '20 at 8:24
3

You need get global npm prefix be in your PATH variable, which seems is not your case, to learn what is your system npm global prefix path use the "npm get prefix -g" command.

"npm get prefix" command just prints the local prefix, as the npm documentation said it [1]. In your case npm global prefix, I guess, will be such: /home/alex/.npm-global/bin

So the simplest solution for problem is to add global npm path, which is returned by "npm get prefix -g" to the PATH, and in case of my guess of it value was correct, you just do this:

export PATH=$PATH:/home/alex/.npm-global/bin

Also edit ~/.bashrc file or it dependant shell scripts where the npm paths are set to theirs values, and add that global path to $PATH environment variable.

Just in case that will not help, you can check availability of installed command fkill by running:

which fkill

or run ls -l /home/alex/.npm-global/bin

or even search for it there: find /home/alex/.npm* -name fkill

[1] https://docs.npmjs.com/cli/prefix.html

0

The post Global Node modules not installing correctly. Command not found contains several solutions that worked for some people.

One answer worked for the poster, although he first had to again reinstall Manjaro. This answer summarized the article Resolving EACCES permissions errors when installing packages globally, and I quote:

My npm couldn't find global packages as well. I did what Brad Parks suggested: npm config set prefix /usr/local Then I got a EACCES permissions error (DON'T USE sudo npm install -g <package>) and fixed it through the official npm docs: https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally

  1. On the command line, in your home directory, create a directory for global installations: mkdir ~/.npm-global
  2. Configure npm to use the new directory path: npm config set prefix '~/.npm-global'
  3. In your preferred text editor, open or create a ~/.profile file and add this line: export PATH=~/.npm-global/bin:$PATH
  4. On the command line, update your system variables: source ~/.profile
  5. Then install a package globally and test it! For example: ``` npm install -g awsmobile-cli awsmobile configure
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.