问题
I don't have chrome installed and I mainly use other browsers for development (opera, yandex etc). But the command:
cordova run browser
uses chrome by default, so it fails with " The system can not find the file chrome.". Can I change which browser cordova uses?
回答1:
The only way to change the default Chrome browser is using the --target option.
As you can see Chrome is the default browser for the run command.
Internally, the cordovaServe.launchBrowser function is called with cli arguments.
This function is defined in the cordova-serve/serve.js file and you can find its body in the cordova-serve/src/browser.js file where you can find the complete list of supported browsers for each platform:
var browsers = {
'win32': {
'ie': 'iexplore',
'chrome': 'chrome --user-data-dir=%TEMP%\\' + dataDir,
'safari': 'safari',
'opera': 'opera',
'firefox': 'firefox',
'edge': 'microsoft-edge'
},
'darwin': {
'chrome': '"Google Chrome" --args' + chromeArgs,
'safari': 'safari',
'firefox': 'firefox',
'opera': 'opera'
},
'linux' : {
'chrome': 'google-chrome' + chromeArgs ,
'chromium': 'chromium-browser' + chromeArgs,
'firefox': 'firefox',
'opera': 'opera'
}
};
I hope that this answer will help you to learn a bit more about cordova and the way it works.
回答2:
Test the following command:
cordova run browser --target=firefox
来源:https://stackoverflow.com/questions/38075283/how-to-change-default-browser-of-cordova-browser-platform