Home >Web Front-end >Front-end Q&A >How to configure the nodejs running environment
Step 1: Install Node.js, npm and configure the PATH environment variable. Step 2: Verify the installation, Step 3: Create the project, Step 4: Install the package, Step 5: Run the application.
How to configure the Node.js running environment
Step 1: Install Node.js
Download and install the latest version of Node.js from the Node.js official website. Follow the instructions of the installation wizard.
Step 2: Install npm
npm is the package management tool for Node.js. Make sure it is installed. If it is not installed yet, run the following command in the terminal:
<code>npm install -g npm</code>
Step 3: Configure the PATH environment variable
Add the executables for Node.js and npm to PATH environment variable so that they can be used in any directory.
Windows:
Mac/Linux:
<code>echo 'export PATH=$PATH:/usr/local/bin' >> ~/.bashrc</code>
Step 4 :Verify installation
Run the following command in the terminal to verify that Node.js and npm are installed and configured correctly:
<code>node -v npm -v</code>
Step 5: (Optional) Install Other tools
As needed, you can install other tools such as Yeoman, Webpack or ESLint. These tools can help you manage projects, build applications, or check for code errors.
Step 6: Create the project
Create a directory for the new Node.js project. Node.js applications and management packs can be run in this directory.
Step 7: Install packages
Use npm to install the packages required for the project. In the project directory, run the following command:
<code>npm install <package-name></code>
Step 8: Run the application
Run the Node.js application using the following command:
<code>node <script-name.js></code>
Note:
The above is the detailed content of How to configure the nodejs running environment. For more information, please follow other related articles on the PHP Chinese website!