npm start

作者: 9b559869875b | 来源:发表于2017-11-17 11:08 被阅读16次

    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)

    })   //如果启动成功,在回调函数里打印出服务器端口

    相关文章

      网友评论

          本文标题:npm start

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