Installing npm locally. Possible to ship a npm distribution with your app?

69 views
Skip to first unread message

Thomas Fritz

unread,
Jun 25, 2012, 2:45:29 AM6/25/12
to nodejs list
Hi,

Is it possible to install and package npm totally self contained in your application distribution? There is the env var 'npm_config_prefix' at install time, which works, but it searches the node binary 'globally' in the PATH with 'which' as i have seen. But i ship 'node' also with my application. Is it possible to install and configure npm so i can ship it with my applications distribution.
I have created https://github.com/thomasfr/node-boilerplate-app as an example.

Kind regards

Thomas Fritz

unread,
Jun 25, 2012, 9:48:20 AM6/25/12
to nodejs list
So i tried again with customized PATH variable.

I called the install.sh it like:
"PATH=/home/thomas/Projekte/Privat/node-boilerplate-app/bin:$PATH
npm_config_prefix=/home/thomas/Projekte/Privat/node-boilerplate-app
/home/thomas/Projekte/Privat/node-boilerplate-app/install.sh"
I have a node binary installed in
'/home/thomas/Projekte/Privat/node-boilerplate-app/bin' which is the
first directory in the $PATH env.
When i call "/home/thomas/Projekte/Privat/node-boilerplate-app/bin/npm
config ls -l" afterwards i get the following:

---- snip -----
bin/npm config ls -l
; cli configs
long = true

; userconfig /home/thomas/.npmrc
_auth = ---sekretz---
_password = ---sekretz---
email = "frit...@gmail.com"
username = "thomasfr"

; globalconfig /home/thomas/.nvm/v0.7.12/etc/npmrc
package-config:foo = "boo"

; builtin config
/home/thomas/Projekte/Privat/node-boilerplate-app/lib/node_modules/npm/npmrc
always_auth = 0
; argv = "{\"remain\":[],\"cooked\":[\"install\"],\"original\":[\"install\"]}"
(overridden)
browser = "google-chrome"
ca = "-----BEGIN CERTIFICATE-----\nxxxxxxxxxxxxxxxxx\n-----END CERTIFICATE-----"
cache = "/home/thomas/.npm"
cache_max = null
cache_min = 0
color = true
coverage = true
depth = 0
description = true
dev = true
editor = "vim"
email = "x...@yyy.zzz"
force = true
git = "git"
global = true
globalconfig = "/home/thomas/.nvm/v0.7.12/etc/npmrc"
globalignorefile = "/home/thomas/.nvm/v0.7.12/etc/npmignore"
group = 1000
https_proxy = 0
ignore = ""
init_author_email = 0
init_author_name = 0
init_author_url = 0
init_module = "/home/thomas/.npm-init.js"
init_version = "0.0.0"
json = true
link = true
loglevel = "http"
long = true
message = "%s"
node_version = "0.7.12"
npat = true
npaturl = "http://npat.npmjs.org/"
onload_script = 0
outfd = 1
parseable = true
pre = true
prefix = "/home/thomas/Projekte/Privat/node-boilerplate-app"
production = true
proprietary_attribs = true
rebuild_bundle = true
registry = "https://registry.npmjs.org/"
rollback = true
save = true
save_bundle = 0
save_dev = 0
save_optional = 0
searchexclude = ""
searchopts = ""
searchsort = "name"
shell = "/bin/bash"
strict_ssl = true
tag = "latest"
tmp = "/home/thomas/tmp"
umask = "022"
unicode = true
unsafe_perm = true
usage = true
user = 1000
user_agent = "npm/1.1.30 node/v0.7.12"
userconfig = "/home/thomas/.npmrc"
userignorefile = "/home/thomas/.npmignore"
version = true
versions = true
viewer = "man"
yes = true

; default values
always-auth = false
browser = "google-chrome"
ca = "-----BEGIN CERTIFICATE-----\nxxxxxxxxxxxxx\n-----END CERTIFICATE-----"
cache = "/home/thomas/.npm"
cache-max = null
cache-min = 0
color = true
; coverage = false (overridden)
; depth = null (overridden)
description = true
; dev = false (overridden)
editor = "vim"
; force = false (overridden)
git = "git"
; global = false (overridden)
globalconfig = "/home/thomas/.nvm/v0.7.12/etc/npmrc"
globalignorefile = "/home/thomas/.nvm/v0.7.12/etc/npmignore"
group = 1000
ignore = ""
init-module = "/home/thomas/.npm-init.js"
init.version = "0.0.0"
init.author.name = ""
init.author.email = ""
init.author.url = ""
; json = false (overridden)
; link = false (overridden)
loglevel = "http"
; long = false (overridden)
message = "%s"
node-version = "0.7.12"
npaturl = "http://npat.npmjs.org/"
; npat = false (overridden)
onload-script = null
outfd = 1
; parseable = false (overridden)
; pre = false (overridden)
; prefix = "/home/thomas/.nvm/v0.7.12" (overridden)
; production = false (overridden)
proprietary-attribs = true
proxy = null
https-proxy = null
user-agent = "npm/1.1.32 node/v0.7.12"
rebuild-bundle = true
registry = "https://registry.npmjs.org/"
rollback = true
; save = false (overridden)
save-bundle = false
save-dev = false
save-optional = false
searchopts = ""
; searchexclude = null (overridden)
searchsort = "name"
shell = "/bin/bash"
strict-ssl = true
tag = "latest"
tmp = "/home/thomas/tmp"
unicode = true
unsafe-perm = true
; usage = false (overridden)
; user = "nobody" (overridden)
; username = "" (overridden)
userconfig = "/home/thomas/.npmrc"
userignorefile = "/home/thomas/.npmignore"
umask = "022"
; version = false (overridden)
; versions = false (overridden)
viewer = "man"
; yes = null (overridden)
_exit = true

--- snip ---

As you can see there are some directories set outside the defined
'npm_config_prefix' like
globalconfig=/home/thomas/.nvm/v0.7.12/etc/npmrc
How can i setup npm into my application directly, so i can just pack
it, copy it to another machine, unpack it and run it with
$APPLICATION_DIR/bin/npm

Kind regards



---

Thomas FRITZ
web http://fritzthomas.com
twitter http://twitter.com/thomasf


2012/6/25 Thomas Fritz <frit...@gmail.com>:
Reply all
Reply to author
Forward
0 new messages