2

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?

liam xu
  • 2,892
  • 10
  • 42
  • 65

2 Answers2

2

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.

Esteban
  • 2,540
  • 21
  • 27
0

Quick edit as I see this has already been answered above.

To find the install location of packages installed globally through npm, run the following:

npm config get prefix

to update this you can use the following command:

npm config set prefix path

Source: npm global path prefix

Community
  • 1
  • 1
Tim Anstee
  • 18
  • 1
  • 2
  • Actually, you're missing the `-g` or `--global` flag. Without it, he'd get the local prefix (which might or might not be the same as the global one, depending on where it's executed). – Esteban Jan 14 '16 at 03:06
  • I ran './npm config get prefix', got /usr/local/bfadmin/node, but sinopia can not be found inside it, this directory is node binary itself. – liam xu Jan 14 '16 at 03:16
  • Pretty sure I am right, see https://docs.npmjs.com/misc/config#prefix. Thing I was missing was a path after the set statement. Updating it now. liam, npm should be in your path. you shouldn't be running it from your local directory. – Tim Anstee Jan 14 '16 at 04:41