-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Duplicate tabs opened when running 'yarn run serve' #4088
Comments
I have this problem, too. |
I meet this same problem , too. In vue-cli 3.0, it uses 'use strict'
const open = require('opn')
function runOpen(uri, options, log) {
let openOptions = {}
let openMessage = 'Unable to open browser'
if (typeof options.open === 'string') {
openOptions = { app: options.open }
openMessage += `: ${options.open}`
}
return open(`${uri}${options.openPage || ''}`, openOptions).catch(() => {
log.warn(`${openMessage}. If you are running in a headless environment, please do not use the --open flag`)
})
}
module.exports = runOpen In addition to this, vue-cli 3.0 includes another module named /**
* Reads the BROWSER environment variable and decides what to do with it. Returns
* true if it opened a browser or ran a node.js script, otherwise false.
*/
exports.openBrowser = function(url) {
const { action, value } = getBrowserEnv()
switch (action) {
case Actions.NONE:
// Special case: BROWSER="none" will prevent opening completely.
return false
case Actions.SCRIPT:
return executeNodeScript(value, url)
case Actions.BROWSER:
return startBrowserProcess(value, url)
default:
throw new Error('Not implemented.')
}
}
function startBrowserProcess(browser, url) {
// If we're on OS X, the user hasn't specifically
// requested a different browser, we can try opening
// Chrome with AppleScript. This lets us reuse an
// existing tab when possible instead of creating a new one.
const shouldTryOpenChromeWithAppleScript = process.platform === 'darwin' && (typeof browser !== 'string' || browser === OSX_CHROME)
if (shouldTryOpenChromeWithAppleScript) {
try {
// Try our best to reuse existing tab
// on OS X Google Chrome with AppleScript
execSync('ps cax | grep "Google Chrome"')
execSync('osascript openChrome.applescript "' + encodeURI(url) + '"', {
cwd: __dirname,
stdio: 'ignore',
})
return true
} catch (err) {
// Ignore errors.
}
}
// Another special case: on OS X, check if BROWSER has been set to "open".
// In this case, instead of passing the string `open` to `open` function (which won't work),
// just ignore it (thus ensuring the intended behavior, i.e. opening the system browser):
// https://github.com/facebook/create-react-app/pull/1690#issuecomment-283518768
if (process.platform === 'darwin' && browser === 'open') {
browser = undefined
}
// Fallback to open
// (It will always open new tab)
try {
var options = { app: browser }
open(url, options).catch(() => {}) // Prevent `unhandledRejection` error.
return true
} catch (err) {
return false
}
} Does vue make a mistake ?@LinusBorg |
I have got the same problem under Win 10 after I update cli version from 3.4.1 to 3.8.0. What is weird is that problem is not fixed when I revert the update |
Fixed in 3.8.3 |
Version
3.8.2
Reproduction link
https://github.com/kuretru/Bug-demo
Environment info
Steps to reproduce
What is expected?
Chrome only open "http://localhost:8080/admin/" .
What is actually happening?
Chrome open two tabs, and one is wrong.
Remove 'publicPath' in vue.config.js can fix this, but two tabs still appeared.
The text was updated successfully, but these errors were encountered: