Where is npm in the node.js buildpack?

218 views
Skip to first unread message

Dr Nic Williams

unread,
Oct 14, 2013, 3:06:39 PM10/14/13
to vcap...@cloudfoundry.org
I'm trying to deploy the shiny new http://ghost.org blogging platform, which means deploying my first node.js app beyond Hello World examples.

The start command is "npm start". But it seems that "npm" is not in the $PATH during start up.

Either a) ideas for fixing this? b) where is npm located on the file system explicitly?

Nic

--
Dr Nic Williams
Stark & Wayne LLC - consultancy for Cloud Foundry users
twitter @drnic

Dr Nic Williams

unread,
Oct 14, 2013, 3:39:43 PM10/14/13
to vcap...@cloudfoundry.org
The error I see is:

Reading logs/stderr.log... OK
/bin/bash: line 26: npm: command not found


The manifest I'm trying out is:

$ cat manifest.yml 
---
applications:
- name: ghost
  memory: 128M
  instances: 1
  host: ghost-demo
  domain: cfapps.io
  path: .
  services:
    env-sendgrid:
      label: sendgrid
      provider: sendgrid
      version: n/a
      plan: free
    cleardb-env:
      label: cleardb
      provider: cleardb
      version: n/a
      plan: spark
  command: npm start

David Laing

unread,
Oct 14, 2013, 4:14:39 PM10/14/13
to vcap-dev

Nic,

Check that the env vars being set by the buildpack release process are actually getting set in your running environment.

Specifically the release process attempts to set the PATH - https://github.com/heroku/heroku-buildpack-nodejs/blob/master/bin/release

I have a vague recollection that there might be a regression in this area.

D

To unsubscribe from this group and stop receiving emails from it, send an email to vcap-dev+u...@cloudfoundry.org.

Dr Nic Williams

unread,
Oct 14, 2013, 5:25:49 PM10/14/13
to vcap...@cloudfoundry.org
The $PATH I get in my app is:

PATH=/home/vcap/app/bin:/home/vcap/app/node_modules/.bin:/bin:/usr/bin

This is different in some ways from the buildpack path you linked. Notably, /usr/local/bin is missing. But tried /usr/local/bin/npm and that failed too.

PATH: bin:node_modules/.bin:/usr/local/bin:/usr/bin:/bin

David Laing

unread,
Oct 14, 2013, 6:08:56 PM10/14/13
to vcap...@cloudfoundry.org
Nic,

Poking around https://github.com/cloudfoundry/heroku-buildpack-nodejs/blob/master/bin/compile#L183 I don't think NPM is actually installed into the droplet.tgz

Since npm start is actually just a wrapper for running command specified at  https://github.com/TryGhost/Ghost/blob/master/package.json#L6, perhaps you could just set your start command to "node index" ?

D


--
David Laing
Open source @ City Index - github.com/cityindex
http://davidlaing.com
Twitter: @davidlaing

Patrick Mueller

unread,
Oct 14, 2013, 8:09:36 PM10/14/13
to vcap-dev
I believe David is correct; npm is not installed in the droplet; it is installed on the staging box while the buildpack is compile-ing.  I always use `--command "node app.js"` (or whatever) in the cf push invocation.  

I don't think there's a need for having npm available in the droplet, though it would be nice for a node buildpack to figure out the command, if available in the package.json file.
Patrick Mueller
http://muellerware.org

Dr Nic Williams

unread,
Oct 14, 2013, 8:28:15 PM10/14/13
to vcap...@cloudfoundry.org
You are both beautiful people. I had not looked into what "npm start" was doing; and assume it was some magic that I couldn't understand. Probably involving a callback or deeply nested code.

I am now permitted to move on to new errors.

Thanks!
Nic

David Laing

unread,
Oct 15, 2013, 3:25:10 AM10/15/13
to vcap-dev


On 15 Oct 2013 01:28, "Dr Nic Williams" <drnicw...@gmail.com> wrote:
>

> I am now permitted to move on to new errors.

ROFLMAO.  Story of my life!

Reply all
Reply to author
Forward
0 new messages