Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 398694

Summary: Can we infer the path to npm-cli.js?
Product: [ECD] Orion Reporter: Mark Macdonald <mamacdon>
Component: NodeAssignee: libing wang <libingw>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: libingw, mamacdon
Version: 2.0   
Target Milestone: 2.0 RC1   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Mark Macdonald CLA 2013-01-21 18:13:51 EST
Currently, our npm support relies on a config setting to tell us the relative path from the node executable to npm-cli.js, which is the entry point we use to launch npm. For the standard Node installation, this value seems to be
> npm_path = ../lib/node_modules/npm/bin/npm-cli.js

But it doesn't work for every Node install. For example, on my computer I'm using "nodist" [1], which allows me to keep several versions of Node.js installed simultaneously and switch between them. In my case, the important paths are:

node: C:\Users\mamacdon\code\nodist\bin\node.exe
npm: C:\Users\mamacdon\code\nodist\bin\npm.cmd
npm-cli.js: C:\Users\mamacdon\code\nodist\bin\node_modules\npm\bin\npm-cli.js
=> npm_path = ../bin/node_modules/npm/bin/npm-cli.js

We should investigate if there's a more reliable way to guess the location of npm-cli.js...

[1] https://github.com/marcelklehr/nodist
Comment 1 libing wang CLA 2013-01-24 10:57:30 EST
One possible approach may be:
When the user use npm cmd first time we can try to retrieve it around(up and down some levels?) the node exec path. If we can not find it, we should put some message in the cmd output, say :"Can not find the npm-cli.js path, please define it in the orionode.conf and restart sever". Just like when you start java cmd in a normal shell, it will propmt you that your JVM is not in the env path.

By default, the npm path is not in the conf file. So if the user define it we will no longer guess.