What should I do if the node command cannot be found?

藏色散人
Release: 2022-11-07 16:18:35
Original
2562 people have browsed it

The solution to the problem that the node command cannot be found: 1. Check the environment variables; 2. Get the module installation path of Nodejs by executing the "$ npm prefix -g" command; 3. Add the output global installation path to the environment Just put it in the Path entry of the variable.

What should I do if the node command cannot be found?

The operating environment of this tutorial: Windows 7 system, node18.4.0 version, Dell G3 computer.

What should I do if the node command cannot be found?

The solution to the problem that the command cannot be found after Nodejs installs the module globally

When you encounter this problem, record it and see that the prompt should be an environment variable problem. Execute the following command to get the Nodejs Module installation path:

$ npm prefix -g
Copy after login

Just add the output global installation path to the Path entry of the environment variable.

Related introduction:

A module is an independent functional body

One module (main module) introduces other modules (submodules), a Modules are imported by other modules.

In nodejs, a js file (including directory) is a module, and a module is essentially an anonymous function.

is divided into custom modules (modules written by users) and core modules (provided by node modules), third-party modules

Nodejs automatically adds a function to each module. The code in the file is automatically included by the function. The variables and functions inside are local, and the resulting scope is called For the module scope

(function(){
       文件中的代码
})
Copy after login

rquire: is a function (method) used to introduce other modules

module: the object of the current module

module.exports: the object of the current module Export object

__dirname: The absolute directory of the current module Note: dir→directory

__filename: The absolute directory and module name of the current module Note: The underscores are two

module. The public content of exports, that is, the exported object, will be obtained by introducing the module

require() is a function used to introduce other modules (introducing the objects exported by module.exports)

Recommended learning: "nodejs video tutorial"

The above is the detailed content of What should I do if the node command cannot be found?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template