Tag Archives: Node Package Manager

Puppet – Run exec as a specific user

I would like to Puppet to install the node modules which is specified in the Node.js project package.json. But the Puppet agent is run under the root account while the project is owned by another Linux user. The Puppet exec type allows you the specific the running user but it would not include the environmental variables like the $HOME. Those variables have to be set when calling the exec type just like follow.

exec { "install node modules of a nodejs project":
  cwd         => "/home/ykyuen/nodejs-project",
  command     => "npm install",
  user        => "ykyuen",
  environment => ["HOME=/home/ykyuen"],
}

 

If you need to set more than one environmental variable, just add them in an array format.

  environment => ["HOME=/home/ykyuen", "FOO=foo"],

 

Done =)

Reference: Puppet Docs: Type Reference – Exec

Ubuntu – Install Node Ver­sion Man­ager globally for all users

The Node Ver­sion Man­ager(nvm) could help you to manage multiple Node.js installations. The following steps are executed from root account.

1. Install the required packages.

apt-get install build-essential openssl libssl-dev curl

 

2. Create a new user group and add those users which are allowed to manage Node.js installation. The following command create a new group called dev.

groupadd dev

Continue reading Ubuntu – Install Node Ver­sion Man­ager globally for all users

Setup Yeoman in Windows PowerShell

Update @ 2015-09-23: Using PowerShell is just my personal preference, You could use MS-DOS in Windows if your machine doesn’t have PowerShell installed.

1. Download Node.js and install it and make sure you have the npm package manager selected before the installation.
setup-yeoman-in-powershell-1
 
Continue reading Setup Yeoman in Windows PowerShell