Lorenzo
Lorenzo

Reputation: 1049

Node.js and modules on a system where I can't sudo

I would like to use node on a system on which I don't have sudo permissions.

I downloaded node and followed a guide on how to install npm packages globally without sudo permissions.

Node and npm commands works well. My problem is that installed packages (in my case bower and gulp), search for node in /usr/bin/env: node: So if I run bower I get /usr/bin/env: node: No such file or directory

I can't create a ln in that directory because I don't have permission. How can I tell bower and gulp to search for node in another path?

Upvotes: 1

Views: 114

Answers (2)

Louis
Louis

Reputation: 151441

My problem is that installed packages (in my case bower and gulp), search for node in /usr/bin/env: node:

They most certainly do not. Here is the first line in gulp:

#!/usr/bin/env node

It is the same in bower. Note that it does not have any of the two colons that you show.

Your question also suggest you are misinterpreting the error message. There is nothing there that implies you should have sudo capabilities. That message tells you that env is unable to find node. Let me illustrate with a name that does not exist on my system:

$ /usr/bin/env nonexistent
/usr/bin/env: nonexistent: No such file or directory
$ env nonexistent
env: nonexistent: No such file or directory

If I do env node it will start node. The error you are getting is exactly in the form of the error messages above: you get the path used to launch env, which is the full path if that's what was used, the name of the command that was not found and the description of the problem.

Why does it fail? It fails because env is not able to find node among the paths specified in your PATH environment variable.

I don't know what your guide told you but if you install locally, you either have to install in such a way that the binaries of Node will be in a path already covered by your PATH, or you should modify the file that sets your environment variables to add the paths in which node and npm were installed. For bash, you'd modify ~./profile like this:

PATH=/path/to/the/node/binaries:$PATH

I prepend to make sure that the path you want will take precedence over anything that could also be installed in the system locations (/bin, /usr/bin, etc.)

Upvotes: 2

bruno_cw
bruno_cw

Reputation: 1031

Are you able to edit the bowserrc file?

Bower can be configured using JSON in a .bowerrc file. For example:

{
  "directory": "app/components/",
  "analytics": false,
  "timeout": 120000,
  "registry": {
    "search": [
      "http://localhost:8000",
      "https://bower.herokuapp.com"
    ]
  }
}

The config is obtained by merging multiple configurations by this order of importance:

  • CLI arguments via --config
  • Environment variables
  • CLI arguments via --config
  • Environment variables
  • Local .bowerrc located in the current working directory
  • All .bowerrc files upwards the directory tree
  • .bowerrc file located in user’s home folder (~)
  • .bowerrc file located in the global folder (/)

Found in: http://bower.io/docs/config/

Upvotes: 1

Related Questions