vuepress+gitpage搭建博客的时候我就没弄明白node。好多东西都需要node.js和npm。
node究竟是什么?
Node.js是一个基于 对Google V8引擎进行封装 的Javascript运行环境(runtime)。
安装node.js
1.首先到 Node.js官网 下载安装文件。
2.安装,下一步,下一步,一马平川。
mac 默认安装目录/usr/local/bin/node
终端安装:
1、安装homebrew:
-
可以通过
brew -v
来看是否安装了homebrew,如果能正确显示homebrew的版本号,说明homebrew已安装image
-
如果没有安装homebrew,通过终端命令安装
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
2、安装node,在终端中输入命令如下:
brew link node
brew uninstall node
brew install node
作者:测试你个头
链接:https://www.jianshu.com/p/3b30c4c846d1
卸载node.js
参考博文https://blog.csdn.net/shiquanqq/article/details/78032943
配置node.js
3.在 node.js 的安装目录下,分别新建两个文件夹 node_global 和 node_cache (只是推荐这样命名,你也可以根据自己习惯命名)
4.打开 终端,分别执行
npm config set prefix node_global完整路径
npm config set cache node_cache完整路径
配置 npm
安装node.js后,现在的node.js已经自带了npm工具了,但是国外的源很慢,或者服务器连接的问题,为了解决这些问题,同时使用cnpm替换npm,我们通过切换源,切换到国内淘宝的源中。下面是我的操作过程。简单记录便于以后自己查看。
1.查看npm版本
npm -v
2.升级npm版本
npm update
3.查看npm配置
npm config list
4.更换源配置
npm config set registry [https://registry.npm.taobao.org]
npm config list / npm config get registery //检查是否替换成功
5.安装cnpm插件
npm install -g cnpm --registry=[https://registry.npm.taobao.org](https://registry.npm.taobao.org/)
cnpm -v
使用的时候和npm用法一样,开头也是npm。
网友评论