美文网首页
初学nodejs——遇到的第一个问题Cannot find mo

初学nodejs——遇到的第一个问题Cannot find mo

作者: carefree0505 | 来源:发表于2017-04-07 16:19 被阅读0次

dos命令大全
http://jingyan.baidu.com/article/8cdccae99f3d46315513cd47.html

sublime text3配置nodejs运行环境:https://my.oschina.net/ximidao/blog/413101

1.安装好nodejs运行环境,写了一段代码:

var http=require('http');

http.createServer(function(req,res){

res.writeHead(200,{'Content-Type':'text-plain'});

res.end('hello world\n');

}).listen(1337,'127.0.0.1');

console.log('Server runnig at http://127.0.0.1:1337');

2.控制台显示http://127.0.0.1:1337,但是浏览器始终无法访问;

3.linux命令错误如下:

module.js:340

throw err;

^

Error: Cannot find module '/home/wenjiang/hellO.js'

at Function.Module._resolveFilename (module.js:338:15)

at Function.Module._load (module.js:280:25)

at Module.runMain (module.js:492:10)

at process.startup.processNextTick.process._tickCallback (node.js:244:9)

4.我的解决方法是,把js文件放在nodejs目录下,直接将文件拖到nodejs运行器上

最后成功显示

相关文章

网友评论

      本文标题:初学nodejs——遇到的第一个问题Cannot find mo

      本文链接:https://www.haomeiwen.com/subject/fepsbttx.html