【发布时间】:2017-11-10 00:07:48
【问题描述】:
所以我刚开始学习 Angular 2,在 git bash 上运行 npm install 命令并打开我的文本编辑器后,我试图运行 npm start 命令来启动 typescript 和 lite 服务器。一切都很顺利,直到出现此错误[1] [BS] Couldn't open browser (if you are using BrowserSync in a headless environment, you might want to set the open option to false) 并且浏览器没有打开。这是它的外观
`
$ npm start
[1] [BS] Access URLs:
[1] --------------------------------------
[1] Local: http://localhost:3002
[1] External: http://172.30.31.239:3002
[1] --------------------------------------
[1] UI: http://localhost:3003
[1] UI External: http://172.30.31.239:3003
[1] --------------------------------------
[1] [BS] Serving files from: ./
[1] [BS] Watching files...
[1] [BS] Couldn't open browser (if you are using BrowserSync in a headless environment, you might want to set the open option to false)
`
我使用的是 Windows 8 64 位操作系统,Chrome 是默认浏览器
回答了一个相关问题https://stackoverflow.com/a/42845813/8130472,并建议选择将 C:\Windows\System32 添加到系统变量中,但我不知道该怎么做。
此外,在此链接上,https://forums.bignerdranch.com/t/browser-sync-couldnt-open-browser/10936/4 的另一个建议是添加 --browser"chrome.exe"(Windows)。那也没用。
有什么建议吗?还是解决方案?
【问题讨论】:
-
我刚刚在“系统变量”中添加了 PATH 变量作为 C:\Windows\System32 并在重新启动后工作。我仍然不知道它做了什么以及它如何帮助消除错误。所以,如果有人知道它如何通过添加路径变量来消除错误,请告诉我。
标签: angularjs node.js npm browser-sync npm-start