Install NPM into home directory with distribution nodejs package (Ubuntu)

后端 未结 8 1680
忘了有多久
忘了有多久 2020-12-07 06:38

I\'d like to use the distribution Node.js packages (or the chris-lea ppa for more recent releases) but install NPM to my home directory.

This may seem picky, but it

8条回答
  •  广开言路
    2020-12-07 07:26

    Because python does already a great job virtualenv, I use nodeenv. Compared to nvm, you can create multiple environments for the same node version (e.g. two environments for node 0.10 but with different sets of packages).

    ENVNAME=dev1
    
    #  create an environment
    python -m virtualenv ${ENVNAME}
    
    # switch to the newly created env
    source ${ENVNAME}/bin/activate
    
    # install nodeenv
    pip install nodeenv
    
    # install system's node into virtualenv
    nodeenv --node=system --python-virtualenv
    

    The readme is pretty good: https://github.com/ekalinin/nodeenv

提交回复
热议问题