“Nodejs安装”的版本间的差异
跳到导航
跳到搜索
(→进阶) |
|||
(未显示同一用户的12个中间版本) | |||
第1行: | 第1行: | ||
− | = | + | =进阶= |
+ | [https://blog.csdn.net/diyiday/article/details/91439151 alpine之创建最小docker镜像] | ||
− | + | Node.js 是跨平台、开源的 JavaScript 运行环境 | |
+ | =install= | ||
+ | ==Binary How to install Node.js via binary archive on Linux == | ||
+ | [https://nodejs.org/dist/ 所有下载地址] | ||
− | [https:// | + | 也可以直接 apt [https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-ubuntu-20-04 How To Install Node.js on Ubuntu 20.04] |
<pre> | <pre> | ||
第18行: | 第22行: | ||
mv node-v10.16.1-linux-x64/* /home/apps/node/ | mv node-v10.16.1-linux-x64/* /home/apps/node/ | ||
− | echo 'export PATH=/home/apps/node/bin/:$PATH' >> /etc/profile && source /etc/profile</pre> | + | echo 'export PATH=/home/apps/node/bin/:$PATH' >> /etc/profile && source /etc/profile |
+ | |||
+ | |||
+ | 官方的写得不错 就是这个目录比较和平时的不太一致 | ||
+ | |||
+ | cat insnode | ||
+ | VERSION=v14.17.6 | ||
+ | DISTRO=linux-x64 | ||
+ | mkdir -p /usr/local/lib/nodejs | ||
+ | tar -xJvf node-$VERSION-$DISTRO.tar.xz -C /usr/local/lib/nodejs | ||
+ | |||
+ | vi /etc/profile | ||
+ | |||
+ | VERSION=v14.17.6 | ||
+ | DISTRO=linux-x64 | ||
+ | export PATH=/usr/local/lib/nodejs/node-$VERSION-$DISTRO/bin:$PATH | ||
+ | |||
+ | source /etc/profile | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | yum | ||
+ | curl --silent --location https://rpm.nodesource.com/setup_14.x | sudo bash | ||
+ | yum -y install nodejs | ||
+ | node -v | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | </pre> | ||
+ | [https://github.com/nodejs/help/wiki/Installation How to install Node.js via binary archive on Linux] | ||
+ | |||
+ | ==Source Code on alpine== | ||
+ | <pre> | ||
+ | |||
+ | #原因 由于 jenkins版本比较老 所以alpine 3.5 不然可以直接 apk add | ||
+ | apk add linux-headers | ||
+ | |||
+ | |||
+ | apk add --no-cache python gcc g++ make | ||
+ | |||
+ | |||
+ | |||
+ | curl -L https://nodejs.org/dist/v10.5.0/node-v10.5.0.tar.gz nod.tar.gz | ||
+ | |||
+ | |||
+ | /configure | ||
+ | |||
+ | make -j 3 && make install | ||
+ | |||
+ | |||
+ | mv /usr/bin/node /usr/bin/nodebak | ||
+ | |||
+ | ln -s /usr/local/bin/node /usr/bin/node | ||
+ | |||
+ | mv /usr/bin/npm /usr/bin/npmbak | ||
+ | |||
+ | ln -s /usr/local/bin/npm /usr/bin/npm | ||
+ | |||
+ | |||
+ | which npm | ||
+ | which node | ||
+ | |||
+ | node -v | ||
+ | |||
+ | npm -v | ||
+ | |||
+ | npm install --global yarn@rc | ||
+ | |||
+ | |||
+ | trouble | ||
+ | |||
+ | 这个是因为我用错了非常老的 0.10版的 哈哈 | ||
+ | |||
+ | n file included from ../deps/cares/src/ares_cancel.c:15:0: | ||
+ | ../deps/cares/src/ares_setup.h:79:43: fatal error: errno.h: No such file or directory | ||
+ | #include <errno.h> /* needed on windows */ | ||
+ | ^ | ||
+ | |||
+ | </pre> | ||
+ | |||
+ | |||
+ | |||
+ | https://blog.csdn.net/liumiaocn/article/details/102598121 | ||
==Source Code == | ==Source Code == | ||
+ | |||
+ | |||
<pre>1.安装gcc,make,openssl,wget | <pre>1.安装gcc,make,openssl,wget | ||
第68行: | 第163行: | ||
/usr/include –放置了nodejs扩展开发用头文件 | /usr/include –放置了nodejs扩展开发用头文件 | ||
优点是全局安装nodejs模块,直接使用。</pre> | 优点是全局安装nodejs模块,直接使用。</pre> | ||
− | |||
==Docker node.js== | ==Docker node.js== | ||
Docker-compose-nuxt | Docker-compose-nuxt | ||
+ | |||
+ | 记得换 alpine 也是要先build动作的 | ||
https://github.com/evan886/docker-compose-nuxt | https://github.com/evan886/docker-compose-nuxt | ||
+ | 注意 没放nodejs相关文件 状态为 Restarting | ||
[https://www.jianshu.com/p/4288623dfbd6 Docker运行nodejs及调试] | [https://www.jianshu.com/p/4288623dfbd6 Docker运行nodejs及调试] | ||
+ | |||
+ | docker-compose | ||
+ | <pre> | ||
+ | # 之前command是yarn,如今改为yarn && yarn start | ||
+ | version: '3.0' | ||
+ | services: # 服务列表 | ||
+ | node-server: # node服务 | ||
+ | container_name: node-server-container # 容器名称 | ||
+ | image: node:14.15.0 | ||
+ | ports: # 暴露的端口 | ||
+ | - "7007:5088" | ||
+ | volumes: | ||
+ | - .:/data | ||
+ | working_dir: /data | ||
+ | depends_on: # web服务依靠mysql要先等mysql启动 | ||
+ | - mysql | ||
+ | restart: on-failure:5 # 自动重启,失败的话重启5次后停止 | ||
+ | command: yarn && yarn start # 覆盖容器启动后默认执行的命令 | ||
+ | |||
+ | </pre> | ||
==ng 反向代理 == | ==ng 反向代理 == | ||
第100行: | 第217行: | ||
[https://blog.csdn.net/fuck487/article/details/86075724 docker镜像中的Alpine安装nodejs] | [https://blog.csdn.net/fuck487/article/details/86075724 docker镜像中的Alpine安装nodejs] | ||
− | + | [https://rollout.io/blog/using-docker-compose-for-nodejs-development/ Using Docker Compose for NodeJS Development] | |
[https://blog.csdn.net/in_christ/article/details/82107649 centos7 编译安装nodejs 最新版] | [https://blog.csdn.net/in_christ/article/details/82107649 centos7 编译安装nodejs 最新版] |
2024年9月23日 (一) 02:12的最新版本
目录
进阶
Node.js 是跨平台、开源的 JavaScript 运行环境
install
Binary How to install Node.js via binary archive on Linux
也可以直接 apt How To Install Node.js on Ubuntu 20.04
#10.16.3 # wget -c https://nodejs.org/dist/v10.16.3/node-v10.16.3-linux-x64.tar.gz #10.16.1 wget -c https://nodejs.org/dist/v10.16.1/node-v10.16.1-linux-x64.tar.gz tar xvf node-v10.16.1-linux-x64.tar.xz mkdir -p /home/apps/node/ mv node-v10.16.1-linux-x64/* /home/apps/node/ echo 'export PATH=/home/apps/node/bin/:$PATH' >> /etc/profile && source /etc/profile 官方的写得不错 就是这个目录比较和平时的不太一致 cat insnode VERSION=v14.17.6 DISTRO=linux-x64 mkdir -p /usr/local/lib/nodejs tar -xJvf node-$VERSION-$DISTRO.tar.xz -C /usr/local/lib/nodejs vi /etc/profile VERSION=v14.17.6 DISTRO=linux-x64 export PATH=/usr/local/lib/nodejs/node-$VERSION-$DISTRO/bin:$PATH source /etc/profile yum curl --silent --location https://rpm.nodesource.com/setup_14.x | sudo bash yum -y install nodejs node -v
How to install Node.js via binary archive on Linux
Source Code on alpine
#原因 由于 jenkins版本比较老 所以alpine 3.5 不然可以直接 apk add apk add linux-headers apk add --no-cache python gcc g++ make curl -L https://nodejs.org/dist/v10.5.0/node-v10.5.0.tar.gz nod.tar.gz /configure make -j 3 && make install mv /usr/bin/node /usr/bin/nodebak ln -s /usr/local/bin/node /usr/bin/node mv /usr/bin/npm /usr/bin/npmbak ln -s /usr/local/bin/npm /usr/bin/npm which npm which node node -v npm -v npm install --global yarn@rc trouble 这个是因为我用错了非常老的 0.10版的 哈哈 n file included from ../deps/cares/src/ares_cancel.c:15:0: ../deps/cares/src/ares_setup.h:79:43: fatal error: errno.h: No such file or directory #include <errno.h> /* needed on windows */ ^
https://blog.csdn.net/liumiaocn/article/details/102598121
Source Code
1.安装gcc,make,openssl,wget yum install -y gcc make gcc-c++ openssl-devel wget 2.下载源代码包 同样的,你可以在下载页面https://nodejs.org/en/download/中找到下载地址。然后执行指令 wget https://nodejs.org/dist/v9.3.0/node-v9.3.0.tar.gz 3.解压源代码包 tar -xf node-v9.3.0.tar.gz 4.编译 进入源代码所在路径 cd node-v9.3.0 先执行配置脚本 ./configure 编译与部署 make && make install 接着就是等待编译完成… 5.测试 node -v npm 如果正确输出版本号,则部署OK 这种方式安装,个人觉得比较有点麻烦,还有安装gcc等其他程序,对应新人来说可能比较晕。而且编译比较久,切部署完成后nodejs为分别放在好几个文件夹内: /usr/local/bin –放置nodejs 执行程序 /usr/lib –放置了node_modules,即nodejs的各种模块 /usr/include –放置了nodejs扩展开发用头文件 优点是全局安装nodejs模块,直接使用。
Docker node.js
Docker-compose-nuxt
记得换 alpine 也是要先build动作的
https://github.com/evan886/docker-compose-nuxt
注意 没放nodejs相关文件 状态为 Restarting
docker-compose
# 之前command是yarn,如今改为yarn && yarn start version: '3.0' services: # 服务列表 node-server: # node服务 container_name: node-server-container # 容器名称 image: node:14.15.0 ports: # 暴露的端口 - "7007:5088" volumes: - .:/data working_dir: /data depends_on: # web服务依靠mysql要先等mysql启动 - mysql restart: on-failure:5 # 自动重启,失败的话重启5次后停止 command: yarn && yarn start # 覆盖容器启动后默认执行的命令
ng 反向代理
troubleshooting
node: error while loading shared libraries: libuv.so.1: cannot open shared object file: No such file or directory yum install libicu.x86_64 libuv-devel
UNABLE_TO_VERIFY_LEAF_SIGNATURE 错误