下载linux版本的nodejs,网址:https://nodejs.org/en/
下载解压后添加环境变量

gedit ~/.bashrc
export PATH=/home/lhw/Software/node-v16.14.2-linux-x64/bin:$PATH
export LD_LIBRARY_PATH=/home/lhw/Software/node-v16.14.2-linux-x64/lib/node_modules:$LD_LIBRARY_PATH
source ~/.bashrc

export NODE_HOME=/home/lhw/Software/nodejs
export PATH=$PATH:$NODE_HOME/bin 
export NODE_PATH=$NODE_HOME/lib/node_modules

source ~/.bashrc

打开新的终端后测试node -v,显示版本后表示安装正确

安装package


npm install obj2gltf --save -g

# -g 表示全局安装,安装包在node-v16.14.2-linux-x64/lib/node_modules下
# npm install <package_name> --save命令会添加条目到package.json的dependencies中。
# npm install <package_name> --save-dev命令会添加条目到package.json的devDependencies中。

卸载

npm uninstall :从node_modules目录中移除一个包。
npm uninstall --save :从package.json的dependencies中移除一个包。
npm uninstall --save-dev :从package.json的devDependencies中移除一个包。

如果安装报错

npm ERR! code ETIMEDOUT
npm ERR! errno ETIMEDOUT
npm ERR! network request to https://registry.npmjs.org/hexo-deployer-git failed, reason: connect ETIMEDOUT 211.136.113.1:8080
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly.  See: 'npm help config'

代理的问题,更换安装源

npm config set registry "https://registry.npm.taobao.org"

# huawei
npm i --registry=https://mirrors.huaweicloud.com/repository/npm/ 

express

安装

npm install express -g
npm install -g express-generator

测试

express --version
4.16.1

# 创建demo测试,在工程文件夹下
express demo
cd demo 
npm install 
npm start

打开浏览器http://localhost:3000/

版权声明:本文为小小灰迪原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/xiaohuidi/p/16082278.html