Maryo
Maryo

Reputation: 503

Run npm command line without add node to path

I have a folder with last version of node and npm (on ubuntu) :

node
 node_modules
 node
 npm
 npm.cmd

And would like to run node/npm without add node/node in classpath

Because node/npm returns : node/npm: node: not found

Idea ?

Upvotes: 3

Views: 2243

Answers (2)

Adam Jonsson
Adam Jonsson

Reputation: 2244

What you can do is to call the npm-cli.js using node. So in the node folder, you can run npm commands by running:

./node node_modules/npm/bin/npm-cli.js <command> <args>

where and are the npm command and arguments.

Upvotes: 1

johni
johni

Reputation: 5568

This is impossible.

Any executable that you run by writing its name (not including the path) is looked in some pre-defined paths.

If you'd like to run an executable located in some directory, you can execute it only by specifying its full or relative paths.

If you change dir to the containing directory, you can run it by

./executable-name

In your case

./node

Upvotes: 0

Related Questions