node.jsnpmnpm-installsinopia

what's the destination does 'npm install -g xxx' install to?


For instance, npm install -g sinopia

On windows7, I will install the sinopia command and related modules inside C:\Users\xxxx\AppData\Roaming\npm.

On Redhat5, my node and npm command are in /usr/local/clo/ven/node-v4.2.3-linux-x64/bin. When I run 'npm install -g sinopia', by default, sinopia was got installed in the current directory as npm and node like below. enter image description here

But currently I got a linux machine that has got sinopia installed by other person. I can not find the start script of sinopia inside node/bin, and I can find sinopia related stuff like below. enter image description here. Where can I find the start script of sinopia? Whether the installation location of the 'npm install -g xxx' can be configured?


Solution

  • npm installs packages globally to its set global "root". To find what the global root is in a given environment, run npm root -g.

    It will typically be inside the "prefix" directory, which you can find with npm prefix -g.

    Note you can also change the prefix directory with npm config -g set prefix </new/prefix/path>.


    To answer your more specific question

    In order to find the sinopia executable, you can run which sinopia on linux (you might need to install which on RedHat, it should be available in your package sources). It will give you the pathname of the file that would be executed for the sinopia command.

    But that could be a symlink to another location; to resolve the pathname you can use readlink -f $(which sinopia) on bash. The -f option tells readlink to follow links recursively. $(which sinopia) will be substituted by the output of the which sinopia command.