Home  >  Article  >  Web Front-end  >  How to run js files in nodejs

How to run js files in nodejs

青灯夜游
青灯夜游Original
2021-01-25 14:21:3024980browse

How to run js files in nodejs: Open the cmd command window and directly execute the "specific path of node js file name" command; you can also use the cd command in the cmd command window to locate the directory where the js file is located. , and then execute the "node js file name" command.

The operating environment of this article: Acer S40-51, nodejs 14.15.4 version, Windows10 Home Chinese version

Related recommendations: "nodejs video tutorial"

nodejs runs JavaScript script file

1. Create and write JavaScript script file

How to run js files in nodejs

2. Open cmd command window

How to run js files in nodejs

3. Directly execute the "node js file name specific path" command to execute the js script file

My js file is in D:\ nodejs\demo directory, so execute

node D:\nodejs\demo\hello.js

How to run js files in nodejs

4, or first use the "cd directory path" command to locate the directory where the js file is located, and then Execute: node fileName command (fileName file name) to execute the corresponding js script file. Example:

node hello.js

How to run js files in nodejs

Description:

For the js file following node, The .js suffix can be added or not

Note:

It is best not to use node.js and Chinese in the file name, and there should be no spaces in the file name

For more programming-related knowledge, please visit: Introduction to Programming! !

The above is the detailed content of How to run js files in nodejs. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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