Npm install not running properly over puppet

node.jspuppet

I'm having a problem running npm install when using Puppet to set up my application.

I'm using Puppet to set up a node.js application that we will be using live in a few weeks. This application has sqlite3 as a dependency. The problem I run into is when running 'npm install" the sqlite3 dependency has to be compiled from source to run properly. However the correct command:

npm install --build-from-source=sqlite3

Will not run properly using the exec command in Puppet. I have my Puppet code below:

exec { 'npm install --build-from-source=sqlite3' :
    cwd => '/var/video_server',
    user => 'root',
    path => '/usr/local/node/node-default/bin'
}

How do I get either the sqlite3 to properly compile using Puppet? I do not want to have to run npm install manually on every server I set this application up on.

Best Answer

It seems your PATH is not sufficiently configured.
When you build an module from source npm will have to run multiple commands which have to be on your PATH.
So please try this:

exec { 'npm install --build-from-source=sqlite3' :
    cwd => '/var/video_server',
    user => 'root',
    path => ['/usr/local/node/node-default/bin', '/bin', '/usr/bin']
}

hope this helps you out.

To verify yourself it works you could try running as root in /var/video_server :

PATH=/usr/local/node/node-default/bin:/bin:/usr/bin npm install --build-from-source=sqlite3