node.js - npm "scripts": "start" run express and open url

标签 node.js angular express npm

我在 package.json

中有这个启动参数
"scripts": {
    "start": "node bin/www"
  },

当我输入 npm start 时,它正在运行我的 express 应用程序。

但我希望浏览器同时打开 http://localhost:8081。我怎么能对 start 说也打开我的本地 url?

like: "start": "node bin/www, http://localhost:8081"

所以当我输入 npm satrt 时,它会运行我的快速应用程序并同时打开网址。

最佳答案

据我所知,这就像写一个 bash 命令:

// Windows
"start":"start http://localhost:8081 & node bin/www"

// Mac
"start":"open http://localhost:8081 && node bin/www"

// Linux
"start":"xdg-open http://localhost:8081 && node bin/www"

关于node.js - npm "scripts": "start" run express and open url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35261535/

相关文章:

JavaScript 运算符歧义

javascript - Nodejs 使用 httpdispatcher 提供静态图像

Angular 2路由订阅变化检测

unit-testing - Angular 2 单元测试 : How to override a single provider in TestBed (for unit tests for a service, 不是组件,具有服务依赖性)?

javascript - Angular2动态获取组件引用

node.js - 你能在 Node.JS Express 应用程序中插入中间件吗

javascript - Express 路由器未安装

node.js - [Heroku][Node.js] 如何在本地运行自定义时钟进程作业?

node.js - 将路由移动到 Express.js 中的文件中

javascript - 通过表单输入+Express.js向mongodb插入数据