Coder Social home page Coder Social logo

Comments (10)

ljharb avatar ljharb commented on September 27, 2024 1

The issue is that npm root -g is returning the wrong place - specifically, npm config get prefix should not be returning ${HOME}/.local/share/npm. Do you have that defined in ~/.npmrc? If so, remove it.

from nvm.

ljharb avatar ljharb commented on September 27, 2024 1

aha, ok so that's the problem - that's taking precedence over nvm's npm. if you have a system node/npm, either uninstall/remove them, or, make sure that your PATH puts nvm's dirs in front of /usr/bin

from nvm.

omnigenous avatar omnigenous commented on September 27, 2024

@ljharb Commented prefix line from my npm config, now it looks likes this:

#prefix=${XDG_DATA_HOME}/npm # don't use with nvm
cache=${XDG_CACHE_HOME}/npm
init-module=${XDG_CONFIG_HOME}/npm/config/npm-init.js
logs-dir=${XDG_STATE_HOME}/npm/logs
$ echo $(npm root -g)
/usr/lib/node_modules

However npm install -g forever returns error:

npm error code EACCES
npm error syscall mkdir
npm error path /usr/lib/node_modules/forever
npm error errno -13
npm error Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/forever'

from nvm.

ljharb avatar ljharb commented on September 27, 2024

(to be clear, you shouldn't be using prefix ever with anything; the location for global modules shouldn't be overridden)

when nvm has a node version used, npm root -g should return a path that's inside $NVM_DIR. What does npm config get prefix return?

from nvm.

omnigenous avatar omnigenous commented on September 27, 2024

npm config get prefix returns /usr

from nvm.

ljharb avatar ljharb commented on September 27, 2024

ok, so that's the problem. is there anything relevant in env | grep -i prefix?

(do note that tmux sets PREFIX which makes it incompatible with npm)

from nvm.

omnigenous avatar omnigenous commented on September 27, 2024

is there anything relevant in env | grep -i prefix?

Nope, only:

PYTHONPYCACHEPREFIX=/home/user/.cache/python

Not using tmux either

from nvm.

ljharb avatar ljharb commented on September 27, 2024

and which npm still prints ${NVM_DIR}/versions/node/v20.14.0/bin/npm?

from nvm.

omnigenous avatar omnigenous commented on September 27, 2024

Nope, which npm returns /usr/bin/npm

from nvm.

omnigenous avatar omnigenous commented on September 27, 2024

This was such a headache and even after multiple attempts over a span of few days I didn't come close to solving this. Ended up burning out and haven't touch node stuff for entire summer.

Just use fnm so much easier to setup and use, took me couple minute to get it working: https://github.com/Schniz/fnm

yay -S fnm-bin

Add to .zshrc (or more options: https://github.com/Schniz/fnm#shell-setup)

eval "$(fnm env --use-on-cd --shell zsh)"

from nvm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.