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.
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
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(){ 文件中的代码 })
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!