简体   繁体   English

节点命令和文件名

[英]node command and file name

I was working on a project and launched my node server with a mistake inside the command. 我正在一个项目上,并在命令内输入错误启动了节点服务器。

I typed: node index;Js 我输入: node index;Js

Surprisingly, this worked and launched the script correctly, even though my script name is index.js 出乎意料的是,即使我的脚本名为index.js ,它也可以正常运行并启动脚本

Why did this work? 为什么要这样做?

When running a node/npm start, it will expect a js file. 当运行节点/ npm启动时,它将需要一个js文件。 The semi-colon acts as normal and ends the line of code there. 分号充当普通字符并在此处结束代码行。 Much like how you can import modules and leave off the trailing .js 就像您可以导入模块并忽略尾随的.js一样

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM