Npm:修订间差异
无编辑摘要 |
无编辑摘要 |
||
(未显示同一用户的2个中间版本) | |||
第23行: | 第23行: | ||
Some systems need to upgrade to the latest versions to run projects. The company NodeSource specialises in offering high-quality Node assistance for businesses. It keeps an APT repository with several Node.js versions. If your application needs a certain Node.js version, use this repository. For example, some projects need to install >=12 Nodejs version and use the following commands. | Some systems need to upgrade to the latest versions to run projects. The company NodeSource specialises in offering high-quality Node assistance for businesses. It keeps an APT repository with several Node.js versions. If your application needs a certain Node.js version, use this repository. For example, some projects need to install >=12 Nodejs version and use the following commands. | ||
<nowiki>#</nowiki> curl -sL <nowiki>https://deb.nodesource.com/setup_12.x</nowiki> | sudo -E bash - | <nowiki>#</nowiki> curl -sL <nowiki>https://deb.nodesource.com/setup_12.x</nowiki> | sudo -E bash - | ||
<nowiki>#</nowiki> Node.js 12.x is no longer actively supported! | |||
<nowiki> | curl -sL <nowiki>https://deb.nodesource.com/setup_20.x</nowiki> | sudo -E bash - | ||
apt-get install nodejs | |||
To upgrade to the latest versions of npm, use the following command: | |||
<nowiki>#</nowiki> npm install -g npm@latest | |||
<nowiki>#</nowiki> npm install -g npm@latest | |||
Once completed the process of upgrading to check node and npm versions, use the following commands: | Once completed the process of upgrading to check node and npm versions, use the following commands: | ||
node -v | node -v | ||
v20.4.0 | |||
v20.4.0 | npm -v | ||
9.7.2 | |||
npm -v | |||
9.7.2 | |||
==== Note ==== | ==== Note ==== | ||
第49行: | 第43行: | ||
npm install uuid@latest | npm install uuid@latest | ||
[[分类:Develop]] | |||
[[分类:Web]] |
2023年9月22日 (五) 22:45的最新版本
Node.js 发布于 2009 年 5 月,由 Ryan Dahl 开发,是一个基于 Chrome V8 引擎的 JavaScript 运行环境,使用了一个事件驱动、非阻塞式 I/O 模型,让 JavaScript 运行在服务端的开发平台,它让 JavaScrip t成为与 PHP、Python、Perl、Ruby 等服务端语言平起平坐的脚本语言。
Node.js 对一些特殊用例进行优化,提供替代的 API,使得 V8 在非浏览器环境下运行得更好,V8 引擎执行 Javascript 的速度非常快,性能非常好,基于 Chrome JavaScript 运行时建立的平台, 用于方便地搭建响应速度快、易于扩展的网络应用。
Node可以在不新增额外线程的情况下,依然可以对任务进行并发处理 —— Node.js 是单线程的。它通过事件循环(event loop)来实现并发操作,对此,尽可能的避免阻塞操作,多使用非阻塞操作。
npm
node package manger
npm 是 Node 的开放式模块登记和管理系统,是 Node.js 包的标准发布平台,用于 Node.js 包的发布、传播、依赖控制,网址:https://www.npmjs.com/
npm 提供了命令行工具,可以方便地下载、安装、升级、删除包,也可以让你作为开发者发布并维护包
Installation of Nodejs and npm Process
apt install npm node -v v10.19.0 npm -v 6.14.4
Upgrade Nodejs and npm Process
Some systems need to upgrade to the latest versions to run projects. The company NodeSource specialises in offering high-quality Node assistance for businesses. It keeps an APT repository with several Node.js versions. If your application needs a certain Node.js version, use this repository. For example, some projects need to install >=12 Nodejs version and use the following commands.
# curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash - # Node.js 12.x is no longer actively supported!
curl -sL https://deb.nodesource.com/setup_20.x | sudo -E bash - apt-get install nodejs
To upgrade to the latest versions of npm, use the following command:
# npm install -g npm@latest
Once completed the process of upgrading to check node and npm versions, use the following commands:
node -v v20.4.0 npm -v 9.7.2
Note
If we get the following error then use the following command: npm WARN deprecated [email protected]: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic.
npm install uuid@latest