gpt4 book ai didi

reactjs - 为什么 vscode 在边缘而不是 chrome 中打开 React 应用程序?

转载 作者:行者123 更新时间:2023-12-05 03:44:51 35 4
gpt4 key购买 nike

我刚刚用 react-create-app 模板 typescript 开始了一个项目。

当我执行 npm run dev 时,它会打开 edge 浏览器,我期待的是 chrome。

知道如何在 chrome 中打开它吗?

最佳答案

From Create React App documentation

By default, Create React App will open the default system browser,favoring Chrome on macOS. Specify a browser to override this behavior,or set it to none to disable it completely. If you need to customizethe way the browser is launched, you can specify a node scriptinstead. Any arguments passed to npm start will also be passed to thisscript, and the url where your app is served will be the lastargument. Your script's file name must have the .js extension.

简单的答案是更改您的默认浏览器。但是,如果您想将默认浏览器保留为 Edge,您可以这样做。

BROWSER=chrome npm start
BROWSER=chrome npm run dev

请考虑浏览器名称不同。例如,Chrome 在 macOS 上是 google chrome,在 Linux 上是 google-chrome,在 Windows 上是 chrome。

Linux
"start": "BROWSER='google-chrome-stable' react-scripts start"
Windows
"start": "BROWSER='chrome' react-scripts start"
Mac
"start": "BROWSER='google chrome' react-scripts start"

关于reactjs - 为什么 vscode 在边缘而不是 chrome 中打开 React 应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66212423/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com