nodejs环境快速搭建(centos,nvm)
来源:互联网 发布:ubuntu恢复模式怎么用 编辑:程序博客网 时间:2024/06/10 20:37
node.js 环境搭建方式比较快的通常有两种:
1.直接安装官方镜像,手动修改环境变量
2.如果你需要随时切换node.js版本的话,可以使用nvm进行版本控制,
以centos为例:
1.首先需要有git
yum install git
- 有git 之后,直接从github上clone项目到本地
假设放~/git 目录
$ cd ~/git$ git clone https://github.com/creationix/nvm.git
完成后需要执行下载下来的nvm文件
source ~/git/nvm/nvm.sh
3.nvm可以查看nvm的常用命令
$ nvmNode Version ManagerNote: <version> refers to any version-like string nvm understands. This includes: - full or partial version numbers, starting with an optional "v" (0.10, v0.1.2, v1) - default (built-in) aliases: node, stable, unstable, iojs, system - custom aliases you define with `nvm alias foo` Any options that produce colorized output should respect the `--no-colors` option.Usage: nvm --help Show this message nvm --version Print out the installed version of nvm nvm install [-s] <version> Download and install a <version>, [-s] from source. Uses .nvmrc if available --reinstall-packages-from=<version> When installing, reinstall packages installed in <node|iojs|node version number> --lts When installing, only select from LTS (long-term support) versions --lts=<LTS name> When installing, only select from versions for a specific LTS line --skip-default-packages When installing, skip the default-packages file if it exists --latest-npm After installing, attempt to upgrade to the latest working npm on the given node version nvm uninstall <version> Uninstall a version nvm uninstall --lts Uninstall using automatic LTS (long-term support) alias `lts/*`, if available. nvm uninstall --lts=<LTS name> Uninstall using automatic alias for provided LTS line, if available. nvm use [--silent] <version> Modify PATH to use <version>. Uses .nvmrc if available --lts Uses automatic LTS (long-term support) alias `lts/*`, if available. --lts=<LTS name> Uses automatic alias for provided LTS line, if available. nvm exec [--silent] <version> [<command>] Run <command> on <version>. Uses .nvmrc if available --lts Uses automatic LTS (long-term support) alias `lts/*`, if available. --lts=<LTS name> Uses automatic alias for provided LTS line, if available. nvm run [--silent] <version> [<args>] Run `node` on <version> with <args> as arguments. Uses .nvmrc if available --lts Uses automatic LTS (long-term support) alias `lts/*`, if available. --lts=<LTS name> Uses automatic alias for provided LTS line, if available. nvm current Display currently activated version nvm ls List installed versions nvm ls <version> List versions matching a given <version> nvm ls-remote List remote versions available for install --lts When listing, only show LTS (long-term support) versions nvm ls-remote <version> List remote versions available for install, matching a given <version> --lts When listing, only show LTS (long-term support) versions --lts=<LTS name> When listing, only show versions for a specific LTS line nvm version <version> Resolve the given description to a single local version nvm version-remote <version> Resolve the given description to a single remote version --lts When listing, only select from LTS (long-term support) versions --lts=<LTS name> When listing, only select from versions for a specific LTS line nvm deactivate Undo effects of `nvm` on current shell nvm alias [<pattern>] Show all aliases beginning with <pattern> nvm alias <name> <version> Set an alias named <name> pointing to <version> nvm unalias <name> Deletes the alias named <name> nvm install-latest-npm Attempt to upgrade to the latest working `npm` on the current node version nvm reinstall-packages <version> Reinstall global `npm` packages contained in <version> to current version nvm unload Unload `nvm` from shell nvm which [<version>] Display path to installed node version. Uses .nvmrc if available nvm cache dir Display path to the cache directory for nvm nvm cache clear Empty cache directory for nvmExample: nvm install 8.0.0 Install a specific version number nvm use 8.0 Use the latest available 8.0.x release nvm run 6.10.3 app.js Run app.js using node 6.10.3 nvm exec 4.8.3 node app.js Run `node app.js` with the PATH pointing to node 4.8.3 nvm alias default 8.1.0 Set default node version on a shell nvm alias default node Always default to the latest available node version on a shellNote: to remove, delete, or uninstall nvm - just remove the `$NVM_DIR` folder (usually `~/.nvm`)
- 安装任意版本的node
NVM_NODEJS_ORG_MIRROR=https://npm.taobao.org/mirrors/node nvm install 6
直接按y ,过掉
######################################################################## 100.0%Now using node v6.3.2
此时已经安装好node跟 npm ,可以检验一下版本
这里会出现一个问题,等你下次启动centos的时候,会发现node.js用不了,那是因为你没有输入到环境变量的启动上
5.你可以在在 ~/.bashrc, ~/.bash_profile, ~/.profile, 或者 ~/.zshrc 文件添加以下命令:
# nvmexport NVM_NODEJS_ORG_MIRROR=https://npm.taobao.org/mirrors/nodesource ~/git/nvm/nvm.sh
再输入
nvm ls
你可以看到版本的信息
阅读全文
1 0
- nodejs环境快速搭建(centos,nvm)
- 利用NVM搭建Nodejs的开发环境
- CentOS 7快速搭建Nodejs开发环境
- nvm快速 搭建node.js 环境
- CentOS搭建NodeJS环境
- CentOS中搭建NodeJS环境
- 1.nvm环境搭建
- nodejs+express开发环境快速搭建
- CentOS7 快速搭建Nodejs开发环境
- centos下快速搭建LNMP开发环境
- CentOS下快速搭建LAMP环境
- 快速在centos上搭建LAMP环境
- Centos 6.5下KVM环境快速搭建
- nvm nodejs npm 环境配置(个人学习中...)
- Centos6和Ubuntu 下安装nvm和nodeJS开发环境
- CentOS nodejs环境配置
- centos安装nodejs环境
- Centos配置nodejs环境
- 总结(7.10—7.16)
- TensorFlow教程 3 建造神经网络
- Spark-Streaming获取applicationId即scala中获取appid
- IDEA调试(转)
- 字符串英文的倒置输出
- nodejs环境快速搭建(centos,nvm)
- Tcpdump
- java鬼混笔记:nginx 负载均衡 简单配置
- map&reduce&filter
- Python文件操作
- LeetCode-MinimumDepthOfBinaryTree
- 链表相交问题【每日一题】
- X11 和Wayland的区别,一点感悟
- 数据库引擎简介