📅  最后修改于: 2023-12-03 15:14:05.326000             🧑  作者: Mango
Node.js is a powerful JavaScript runtime built on Chrome's V8 JavaScript engine. It allows you to build scalable and high-performance network applications. In this guide, we will explore how to install and use Node.js on Ubuntu.
$ sudo apt update
$ sudo apt install curl dirmngr apt-transport-https lsb-release ca-certificates
$ curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
$ sudo apt install nodejs
$ node -v
$ npm -v
$ sudo apt update
$ sudo apt install nodejs npm
$ node -v
$ npm -v
To create a simple Node.js application, follow these steps:
$ mkdir myapp
$ cd myapp
$ npm init -y
Create a file named app.js
and write your Node.js code in it.
Run your Node.js application:
$ node app.js
npm is the default package manager for Node.js. You can use it to install packages or modules for your Node.js applications. Here are a few useful npm commands:
npm install package_name
npm install package_name --save-dev
npm uninstall package_name
npm update package_name
npm search package_name
For more details, refer to the npm documentation.
In this guide, we have covered the installation of Node.js on Ubuntu and how to create a simple Node.js application. Additionally, we introduced npm, the Node.js package manager. With Node.js, you can build fast and scalable server-side applications using JavaScript.