Home >Web Front-end >JS Tutorial >How to configure and install node.js in IDEA? Brief analysis of methods

How to configure and install node.js in IDEA? Brief analysis of methods

青灯夜游
青灯夜游forward
2022-12-21 20:28:405151browse

How to run

node in IDEA? The following article will introduce to you how to configure, install and run node.js in IDEA. I hope it will be helpful to you!

How to configure and install node.js in IDEA? Brief analysis of methods

idea supports running many programming languages. You only need to install the corresponding language environment on your computer, and then download and install the corresponding language environment in the setting->plugins of idea. Language plug-in, finally find the corresponding language in setting->languages&frameworks and configure the installed language compiler path.

For example node.js

1. Install node.js on your computer

Go directly to the official website to download and install: https ://nodejs.org/zh-cn/
After the installation is complete, use the node --verison command to check. If the version number is displayed, the installation is successful. [Related tutorial recommendations: nodejs video tutorial, Programming teaching]

How to configure and install node.js in IDEA? Brief analysis of methods

And now the node.js installation package comes with npm , you can also see the npm version number by executing the npm -v command on the command line, but the environment variable of the global installation package path will not be automatically configured for npm during installation (if it is not configured, you may report that the package cannot be found when running the js program. mistake). First use the npm list -g command to display the global installation package path, and then add a NODE_PATH variable to the system environment variable to add this path.

How to configure and install node.js in IDEA? Brief analysis of methods

If you want to modify the path of the global npm installation package, please refer to: https://www.cnblogs.com/matanzhang/p/11441693.html

2. Download the node.js support plug-in in the File->setting->plugins of the idea.

Search for node in the plugins and you will see it. Click install to install

How to configure and install node.js in IDEA? Brief analysis of methods

##3. Configure the installed node.js path in File->setting->languages&frameworks And the path of the installation package manager npm

Open setting->languages&frameworks to find node.js, configure the installed node.js path and npm path respectively, npm is usually installed when node.js is installed It comes with it, and idea can usually automatically identify the installed path, just click the drop-down and select it.

How to configure and install node.js in IDEA? Brief analysis of methods After the configuration is completed, you can now happily write and run js programs in idea

4. About npm package management Problem

It is worth noting that you may encounter the problem that it can run in the command line but when running in idea, an error message cannot be found. This is most likely because when installing the package, For local installation instead of global installation, there are two ways to install packages in npm, as follows

Partial installation

Command

npm install xxxx
npm will create a node_modules directory in the directory where the local installation command is executed and install it in this directory. Only the js program in the directory where the command is executed or its subdirectory can access the partially installed package. npm list lists locally installed packages in the current directory.

Global installation

If you want to use the installed package anywhere, you need to add a global command -g## during installation. #
npm install xxxx -g

Globally installed packages are installed directly into the computer. You only need to install them once, and you can use this package anywhere on the computer in the future; npm list -g lists globally installed packages and also displays global installations. path of. The directory of the global installation package is generally in the Appdata directory of the user directory, such as C:\Users\syc\AppData\Roaming\npm

If the error still reports that the package cannot be found, it may be the global installation package. The path is not configured in the environment variable and needs to be configured.

For more node-related knowledge, please visit:

nodejs tutorial

!

The above is the detailed content of How to configure and install node.js in IDEA? Brief analysis of methods. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete