简体   繁体   English

错误:运行“http”时找不到模块“moduleIntro.js”

[英]Error: Cannot find module “moduleIntro.js” when running “http”

I tried a basic beginner program in Node.Js where I wanted to use the built-in module 'http'.我在 Node.Js 中尝试了一个基本的初学者程序,我想在其中使用内置模块“http”。 After executing a basic program of http.createServer().执行 http.createServer() 的基本程序后。 Below is my source code.下面是我的源代码。

var http = require('http');


http.createServer(function (req, res) {
  res.write('Hello World!'); 
  res.end(); 
}).listen(8080);

When running the code in cmd it didn't run and displayed the following error.在 cmd 中运行代码时,它没有运行并显示以下错误。

events.js:287
      throw er; // Unhandled 'error' event
      ^

Error: listen EADDRINUSE: address already in use :::8080
    at Server.setupListenHandle [as _listen2] (net.js:1313:16)
    at listenInCluster (net.js:1361:12)
    at Server.listen (net.js:1449:7)
    at Object.<anonymous> (F:\NodeJS\first app\w3schools\moduleIntro,.js:7:4)
    at Module._compile (internal/modules/cjs/loader.js:1133:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
    at Module.load (internal/modules/cjs/loader.js:977:32)
    at Function.Module._load (internal/modules/cjs/loader.js:877:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
    at internal/main/run_main_module.js:18:47
Emitted 'error' event on Server instance at:
    at emitErrorNT (net.js:1340:8)
    at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  code: 'EADDRINUSE',
  errno: 'EADDRINUSE',
  syscall: 'listen',
  address: '::',
  port: 8080
}

Ok, it's not problem in your code actually 8080 already running anywhere else so you can't run the same port number at a time so just close all running process Or you just shut down your PC and run again the problem will be resolve.好的,您的代码实际上没有问题 8080 已经在其他任何地方运行,因此您不能一次运行相同的端口号,因此只需关闭所有正在运行的进程,或者您只需关闭 PC 并再次运行,问题就会得到解决。

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

相关问题 错误:运行 npm 启动时找不到模块“js-yaml” - Error: Cannot find module 'js-yaml' when running npm start node.js 在运行 babel 脚本时找不到模块 - node.js cannot find module when running babel script 找不到在 docker 环境中运行的节点 js 应用程序的模块错误 - Cannot find module error for a node js app running in a docker environment 运行Protractor时找不到模块&#39;../built/cli.js&#39; - Cannot find module '../built/cli.js' when running Protractor 运行测试用例时出现节点错误“找不到模块” - Node error 'Cannot find module' when running test case 运行服务器时找不到模块&#39;../lib/cli&#39;错误 - Cannot find module '../lib/cli' error when running server discord.js 中的机器人运行错误(错误:找不到模块/代码:'MODULE_NOT_FOUND',requireStack:[]) - Bot running error in discord.js (Error: Cannot find module / code: 'MODULE_NOT_FOUND', requireStack: []) 错误:找不到运行节点 js 和 express.js 应用程序的模块 - Error: Cannot find module running node js and express.js app 将 Js 转换为 Ts 错误找不到模块 - Converting Js to Ts error cannot find module 在Amazon Linux中以普通用户身份运行时,Node JS找不到模块&#39;node-properties-parser&#39;错误 - Node JS Cannot find module 'node-properties-parser' Error while running as normal user in Amazon Linux
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM