npm start 会在package.json 的scripts 里找 start 对应的命令
执行,比如
"scripts": {
"start": "babel-node ./bin/www"
}
$ npm start
> .........
> babel-node ./bin/www
如果打开./bin/www 文件,也能看到设置web服务器端口的代码
app.set('port', process.env.PORT || 3000) //设置端口
const port = app.get('port') //读取端口
const server = app.listen(port, () => {
console.log(' port : ' + server.address().port)
}) //如果启动成功,在回调函数里打印出服务器端口
网友评论