Nodejs环境配置

安装nodejs

1. 下载安装包并解压

cd /home/lyc
mkdir java && mkdir software && cd software
wget https://nodejs.org/dist/v7.10.0/node-v7.10.0-linux-x64.tar.gz
tar -xvzf node-v7.10.0-linux-x64.tar.gz -C ../java/

2.添加node软链接

sudo ln -s /home/lyc/java/node-v7.10.0-linux-x64/bin/node /usr/bin/node
sudo ln -s /home/lyc/java/node-v7.10.0-linux-x64/bin/npm /usr/bin/npm

3.设置为淘宝镜像源

npm config set registry http://registry.npm.taobao.org/
或者采用 nrm 来管理镜像

4.安装 nrm 管理

sudo npm install -g nrm
NOTE: nrm 命令可能不识别,原因使path没有加,在/etc/profile 文件最后添加一下代码,然后source /etc/profile
export PATH=/home/Java/node-v7.10.0-linux-x64/bin:$PATH

5.查看npm全局配置

npm root -g
# 或使用
npm config list

6.nrm添加淘宝镜像

nrm add taobao http://registry.npm.taobao.org/

7.查看npm镜像

nrm list

8.nrm切换到淘宝镜像

nrm use taobao

9.设置国内难下载的包,采用淘宝的源

npm config set electron_mirror https://npm.taobao.org/mirrors/electron/
npm config set sass_binary_site https://npm.taobao.org/mirrors/node-sass/
npm config set phantomjs_cdnurl https://npm.taobao.org/mirrors/phantomjs/
npm config set chromedriver_cdnurl https://npm.taobao.org/mirrors/chromedriver/

npm安装node canvas ubuntu需安装组件

sudo apt-get install libcairo2-dev libjpeg8-dev libpango1.0-dev libgif-dev build-essential g++

npm install 问题

Same failure on macOS when running sudo npm install --global phantomjs-prebuilt (local install worked). It's installed in a global context for pageres-cli.

This looks suspect:

Copying extracted folder /tmp/phantomjs/phantomjs-2.1.1-macosx.zip-extract-1535580170447/phantomjs-2.1.1-macosx -> /usr/local/lib/node_modules/phantomjs-prebuilt/lib/phantom
chmod failed: phantomjs was not successfully copied to /usr/local/lib/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs

Pre-creating /usr/local/lib/node_modules/phantomjs-prebuilt/lib/phantom doesn't help, the installer removes it then still fails when it's not found.

Got it to work by adding --unsafe-perm according to this answer. Doesn't sound like a good solution though.

npm install -g phantomjs-prebuilt@2.1.16 --unsafe-perm

其他

Sonatype Nexus 搭建maven本地仓库

  • 下载nexus
wget https://sonatype-download.global.ssl.fastly.net/nexus/3/nexus-3.5.1-02-unix.tar.gz
具体内容可见:https://www.sonatype.com/download-oss-sonatype

命令行安装下载jdk

wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" https://download.oracle.com/otn-pub/java/jdk/8u191-b12/2787e4a523244c269598db4e85c51e0c/jdk-8u191-linux-x64.tar.gz?AuthParam=1544765340_f34fcde80264b105a676adc83d3cb91e

评论

暂无评论