softasap.sa-node-nvm
sa-node-nvm
This tool installs the Node Version Manager (nvm) and optionally Node.js. It's great for development purposes. If you need a binary installation, check out the sa-node role.
You can specify the Node.js version like this: nodejs_version: "0.10.38"
(This can be any specific version).
Example Usage:
- {
role: "sa-node-nvm",
nvm_version: "0.31.1"
}
- {
role: "sa-node-nvm",
nvm_version: "0.31.1",
deploy_user: "{{ansible_user_id}}",
option_nodejs_install_with_nvm: true,
nodejs_version: "0.12",
option_integrate_w_bash: true,
option_integrate_w_zsh: true
}
Using nvm in Future Steps:
- name: Detect npm
shell: 'source /home/{{deploy_user}}/.profile && dirname "`which npm`"'
args:
executable: /bin/bash
register: npm_path_detected_raw
- name: WSI Workplace | Install bower
npm: name=bower state=present version="{{bower.version}}" global=yes
become: "{{npm_is_global}}"
environment:
PATH: "{{npm_path_detected}}:{{ ansible_env.PATH }}"
Windows Support
For Windows, ensure your system is set up for Ansible provisioning. It's best to use the role sa-box-bootstrap-win, but you can configure it manually if needed.
Example of a Typical Windows Play:
vars:
- root_dir: ..
- ansible_connection: winrm
- ansible_ssh_port: 5986
- ansible_winrm_server_cert_validation: ignore
- ansible_winrm_transport: ssl
pre_tasks:
- debug: msg="Pre tasks section"
- name: gather facts
setup:
roles:
- {
role: "sa-node-nvm"
}
Remember, this is not exactly like the Linux version of nvm, so some commands are different. For example, to activate nvm on Windows, use nvm on
.
Using with Ansible Galaxy Workflow
If you installed the sa-node-nvm role with the command:
ansible-galaxy install softasap.sa-node-nvm
You will find the role in the folder library/softasap.sa-node-nvm
. Make sure to adjust the path accordingly.
- {
role: "softasap.sa-node-nvm"
}
Copyright and License
This code is available under the BSD 3 clause and the MIT License. Choose the one that works best for you.
Contact Us:
- Subscribe for updates on roles at FB
- Join the discussion on Gitter
- Explore other roles at SoftAsap Role Registry
- Visit our blog at SoftAsap Blog
Node Version Manager (nvm) - tool that allows to install and use multiple node versions on the same host
ansible-galaxy install softasap.sa-node-nvm