所以我刚刚开始学习 Angular 2 并运行之后npm install
git bash 上的命令并打开我的文本编辑器,我试图运行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)
。那也没用。
有什么建议么?还是解决方案?
因此,当我继续浏览时,我在此网页上找到了解决此问题的线索https://gist.github.com/Kenty/9096000/revisions这暗示我可以从错误消息中找到打开选项。我决定寻找"bs.config.js"
在我的电脑上,我发现了一个名为default.config.js
in my \Template\node_modules\browser-sync\lib
我的 Angular 文件夹下有一个文件夹,当我搜索该文件时,我终于找到了打开选项,并将打开选项从“local”(这是默认选项)更改为 false(注意,它没有引号),当我运行npm start
再次命令,在 git-bash 终端上它起作用了,并且没有更多错误。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)