Npm“脚本”:“开始”运行快递和打开url
我有这个开始params在package.json
"scripts": { "start": "node bin/www" },
它正在运行我的espress应用程序,我正在打字npm start
。
但是我希望浏览器同时打开http://localhost:8081
。 我怎么能说start
打开我的本地url?
例如: "start": "node bin/www, http://localhost:8081"
所以当我inputnpm satrt
它会运行我的快车应用程序,并同时打开url。
据我所知这就像写一个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"
对于跨平台的支持使用opn 。
安装它:
npm install --save-dev opn-cli
将其添加到脚本中:
"start": "opn http://localhost:8081 && node bin/www"
你只需要使用正确的顺序start
!
"start": "npm run dev & start http://localhost:8000",
坏
"start": "start http://localhost:8000 & npm run dev",
好