[英]node index.js command start and end server in the same time
I did install WSL2 and ubuntu 22.04 distribution on windows 11. I configured envoirment, installed nvm, node v.16.17.1, next in my folder did npm init, installed express, created index.js file within simple structure:我确实在 windows 11 上安装了 WSL2 和 ubuntu 22.04 发行版。我配置了环境,安装了 nvm,节点 v.16.17.1,接下来在我的文件夹中进行了 npm 初始化,安装了 express,在简单结构中创建了 index.js 文件:
const express = require('express')
const app = express()
const port = 3000
app.get('/', (req, res) => {
res.send('Hello World!')
})
app.listen(port, () => {
console.log(`Example app listening on port ${port}`)
})
When i tap node index.js
nothing happen.当我点击
node index.js
时,什么也没有发生。 image图片
In my second computer with ubuntu 20.04 distribution everything work fine.在我使用 ubuntu 20.04 发行版的第二台计算机中,一切正常。 Does anyone know what to do?
有谁知道该怎么办?
How about doing debugging by referring to https://expressjs.com/en/guide/debugging.html ?参考https://expressjs.com/en/guide/debugging.html调试一下如何?
like this,像这样,
DEBUG=express:* node index.js
If no other problem is found, it would be good to use the --inspect
options.如果没有发现其他问题,最好使用
--inspect
选项。 https://nodejs.org/en/docs/guides/debugging-geting-started/ https://nodejs.org/en/docs/guides/debugging-geting-started/
Problem resolve.问题解决。 File need to be SAVE before calling from terminal....
在从终端调用之前需要保存文件....
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.