I've been searching for a while to try to find the answer to this. I've tried everything I've found that makes sense and more. Nothing has worked. Here's the breakdown:
- I'm on linux (
12.3-RELEASE FreeBSD 12.3-RELEASE r371270 NFSN64 amd64
) - I've installed a package called
hexo-cli
usingnpm
. - My home directory is
/home/private
- My global npm install directory is
/home/private/.npm-global
- My
npm prefix -g
location is:/home/private/.npm-global
- When my
cwd
is/home/public/
and I executehexo
,hexo
runs hexo
then fails to find itself because it's using thenpm prefix
(this is my guess)- When I type
npm prefix
it always returns mycwd
- I have checked
/home/private/.npmrc
file. Agrep "prefix" /home/private/.npmrc
returns: prefix=/home/private/.npm-global
- There are no other lines or entries returned from the
grep
npm config set prefix=/home/private/.npm-global
only modifies the global prefix, not my local prefix
How do I get my local prefix var to be /home/private/.npm-global
?
Edit:
Here is the output of my terminal when running hexo
:
[username /home/public]$ hexoERROR Cannot find module 'hexo' from '/home/public'ERROR Local hexo loading failed in /home/publicERROR Try running: 'rm -rf node_modules && npm install --force'
Edit #2:
Forgot to mention. I also tried adding the following two lines to my ~/.profile file:
export PATH=~/.npm-global/bin:$PATHexport PATH=~/.npm-global/lib/node_modules:$PATH
I would then source ~/.profile
.
This made absolutely no difference.
Edit #3:
Fixed a path in the 6th bullet point.
Edit #4
This is the output of my npm config list
:
[username /home/public]$ npm config list; "user" config from /home/private/.npmrcprefix = "/home/private/.npm-global"; node bin location = /usr/local/bin/node; node version = v16.16.0; npm local prefix = /home/public; npm version = 8.13.0; cwd = /home/public; HOME = /home/private/; Run `npm config ls -l` to show all defaults.
Notice it says npm local prefix
. Attempting to npm config set local prefix ...
does not work. local prefix
is not a variable you can assign a value to. I tried localprefix
as well. This did not work.