示例#>
🌐 Example张掖铝皮保温工程
使用 Node.js 编写的 网罗奇迹器 示例,它会反映 'Hello, World!' :
🌐 An example of a web server written with Node.js which responds with 'Hello, World!':
本文档中的呐喊以 $ 或 > 起首,以模拟它们在用户终局中出现的式。不要包含 $ 和 > 字符。它们仅仅用来示每个呐喊的运行。
🌐 Commands in this document start with $ or > to replicate how they would appear in a user's terminal. Do not include the $ and > characters. They are there to show the start of each command.
不以 $ 或 > 字符起首的行示前个呐喊的输出。
🌐 Lines that don't start with $ or > character show the output of the previous command.
先,确保已下载并装配 Node.js。关联多装配信息,请参见 通过包措置器装配 Node.js。
🌐 First, make sure to have downloaded and installed Node.js. See Installing Node.js via package manager for further install information.
当今,创建个名为 projects 的空技俩文献夹张掖铝皮保温工程,然后插足该文献夹。
🌐 Now, create an empty project folder called projects, then navigate into it.
Linux 和 Mac:
🌐 Linux and Mac:
mkdir ~/projects cd ~/projects 拷贝
Windows CMD:
mkdir USERPROFILE\projects cd USERPROFILE\projects 拷贝
Windows PowerShell:
mkdir $env:USERPROFILE\projects cd $env:USERPROFILE\projects 拷贝
接下来,在 projects 文献夹中创建个新的源文献,并将其定名为 hello-world.js。
🌐 Next, create a new source file in the projects folder and call it hello-world.js.
在你可爱的任何文本剪辑器中开 hello-world.js,并粘贴以下实质:
🌐 Open hello-world.js in any preferred text editor and paste in the following content:
邮箱:215114768@qq.comconst http = require('node:http');
const hostname = '127...1';
const port = 3;
const server = http.createServer((req, res) => {
res.statusCode = 2;
res.setHeader('Content-Type', 'text/plain');
res.end('Hello, World!\n');
});
server.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);
}); 拷贝
保存文献。然后,在终局窗口中,铝皮保温要运行 hello-world.js 文献,输入:
🌐 Save the file. Then, in the terminal window, to run the hello-world.js file, enter:
node hello-world.js 拷贝
这么的输出应该出当今终局中:
🌐 Output like this should appear in the terminal:
Server running at http://127...1:3/ 拷贝
当今,盛开荡你可爱的网页浏览器,然后看望 http://127...1:3。
🌐 Now, open any preferred web browser and visit http://127...1:3.
淌若浏览器示字符串 Hello, World!,那就诠释奇迹器正在平素使命。
🌐 If the browser displays the string Hello, World!, that indicates the server is working.
相关词条:罐体保温 塑料挤出设备 钢绞线 超细玻璃棉板 万能胶1.本网站以及本平台支持关于《新广告法》实施的“极限词“用语属“违词”的规定张掖铝皮保温工程,并在网站的各个栏目、产品主图、详情页等描述中规避“违禁词”。
2.本店欢迎所有用户指出有“违禁词”“广告法”出现的地方,并积极配合修改。
3.凡用户访问本网页,均表示默认详情页的描述,不支持任何以极限化“违禁词”“广告法”为借口理由投诉违反《新广告法》,以此来变相勒索商家索要赔偿的违法恶意行为。