Command in parcel.js --open 'google chrome' does not work on Windows, only works on MacOS - parceljs

I use parcel.js to set up my project. This command --open 'google chrome' does not work on Windows, only works on MacOS. The error is: Windows cannot find 'google'. Make sure you typed the name correctly, and then try again.

The browser value passed to --open [browser] is platform-dependent:
Windows: chrome
Linux: google-chrome
MacOS: google chrome
Parcel uses the opn package to start the browser. From the opn documentation:
Type: string | string[]
Specify the app to open the target with, or an array with the app
and app arguments.
The app name is platform dependent. Don't hard code it in reusable
modules. For example, Chrome is google chrome on macOS,
google-chrome on Linux and chrome on Windows.
You may also pass in the app's full path. For example on WSL, this can
be /mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe
for the Windows installation of Chrome.

Related

Live Server does not open in Chrome on Windows 11 and WSL2

I am working in WSL2 on Windows 11 trying to run an index.js file with Live Server. Whenever I open Live Server it seems that I can only do so when I use Microsoft Edge. This seems to add another layer of problems because the JavaScript does not seem to be working as I would expect. For example, if I click a button element I don't see any animations to signify a "click".
I have checked that "liveServer.settings.CustomBrowser": "chrome" is indeed reflectin Chrome in the VS Code settings, but when this is the case there are no windows that pop up at all. The only thing that I see trigger is a notification that tells me that the server is active on Port 5000, just no window popping up to demonstrate that. Ideally I would like to try and open Live Server with Chrome, but if this isn't possible in Windows 11 then is there a way to make JavaScript behave in Microsoft Edge?
I've the same configuration and the same issue. I've raised the issue #2445 in Github.
A workaround solution is to call directly your chrome program installed under windows to your liveserver setting.
check that chrome is well installed on W10 or W11. You can test it by opening a command line and running "start chrome", then chrome browser must open.
look for chrome' installed directory. You can use this command to find it: sudo find /mnt/c/ -type f -iname chrome.exe 2>&1 | grep -v "Permission denied". For me this it's here:mnt/c/Program Files/Google/Chrome/Application.chrome.exe.
Now change liveserver setting on your settings.json file:
{
"liveServer.settings.AdvanceCustomBrowserCmdLine": "/mnt/c/Program Files/Google/Chrome/Application/chrome.exe --remote-debugging-port=9222",
}
Now chrome should start when you run liverserver.
Hope this help

Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable. Flutter 2.0

I updated My flutter Version from 1.22 to 2.0. There are some errors in Flutter Doctor. How Could I solve this. That happen Afer Updated my Flutter Version.
I am Using Android Studion 4.1.2, Ubuntu 20.04.2 LTS(64 bit)
For Ubuntu 20.04, chromium is managed by snap. I set the environment variable as shown below.
CHROME_EXECUTABLE=/snap/bin/chromium
export CHROME_EXECUTABLE
Try 'type chromium' to make sure of the location on your system. I assume something similar will work for chrome.
For ones who use MacOS and with another chromium-based browser than Google Chrome (Brave in my case). You can set in .zshrc or .bashrc
export CHROME_EXECUTABLE="/Applications/Brave Browser.app/Contents/MacOS/Brave Browser"
After that, don't forget to source ~/.zshrc or source ~/.bashrc in the current terminal window.
flutter doctor -v
Now, "Chrome" will be seen as "Brave".
I had the same error in Windows 10, Using VS Code even after setting CHROME_EXECUTABLE system environmental variable to the path of chrome.exe. I solved it by removing the double quotes around the path:
Even though you have a google chrome app in your system. It may have command like google-chrome-stable or chrome or any name to open chrome browser from terminal. Just duplicate the file with google-chrome name in /usr/bin/
Eg: I have google-chrome-stable as executable so my approach is like
sudo cp /usr/bin/google-chrome-stable /usr/bin/google-chrome
You may have bin in snap folder or some other folder depending on your installation way
If you're not having chrome as executable from terminal then create a symbolic link. Find your chrome binary file and use this command
sudo ln -s $PATH/[google-chrome-bin] /usr/bin/google-chrome
Replace [google-chrome-bin] with your binary file name
I'm on a Chromebook. I installed Flutter and Android Studio. When I ran $flutter doctor -v, I got the same error message that you got.
I didn't need to export the file path to my path environment. I just needed to install Chrome so that Flutter could find it on my Chromebook.
Here was the command that worked for me:
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
Then I installed it using the Linux beta command (right click on the downloaded file, install using Linux beta). It installed it to this directory:
/usr/bin/
(Alternatively, for the install, I could've used this command:
sudo apt install ./google-chrome-stable_current_amd64.deb)
I ran flutter doctor -v and now it finds Chrome.
you can export PATH in your .bashrc or .zshrc if you use Linux or MAC OS
you can found installed chrome PATH using which
for example
which google-chrome
# example result : /opt/google/chrome/google-chrome
then add to .zshrc or .bashrc like this
# Chrome PATH
export PATH=$PATH:/opt/google/chrome
then restart source
source .zshrc # change if you use .bashrc
running the flutter doctor
you will see the output like this
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.2.1, on Linux, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version
30.0.3)
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.2)
The answers here have helped me setup Flutter on Mac with Microsoft Edge instead of Chrome.
For that, you simply run from your terminal:
export CHROME_EXECUTABLE="/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge"
If you want to make this permanent, you should add the above line to the file
~/.zshenv or ~/.zshrc
Then save and restart terminal.
For Linux users, you can add Edge Browser like this...
first, add this path in .bashrc file path
PATH=$PATH:/usr/bin/microsoft-edge-stable
then execute this command
export CHROME_EXECUTABLE="/usr/bin/microsoft-edge-stable"
For MacOS Users
cd to /Users/<your user>
sudo nano ~/.zshenv
Add the following:
export PATH="$PATH:/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge"
export CHROME_EXECUTABLE="/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge"
Save the file and restart the IDE terminal
Run flutter doctor
For MacOs User (Vivaldi Browser)
This command sets your PATH variable for the current terminal window only. To permanently add CHROME_EXECUTABLE to your path
export CHROME_EXECUTABLE="/Applications/Vivaldi.app/Contents/MacOS/Vivaldi"
To permanently add CHROME_EXECUTABLE to your path
Open (or create) the rc file for your shell. Typing echo $SHELL in your Terminal tells you which shell you’re using. If you’re using Bash, edit $HOME/.bash_profile or $HOME/.bashrc. If you’re using Z shell, edit $HOME/.zshrc. If you’re using a different shell, the file path and filename will be different on your machine.
If you are using zsh create .zshrc enter a command touch .zshrc which will create a .zshrc file at your hardisk and vice versa for bash.
Go to your finder and press shift + command + H after that again hit a command shift + command + . you will find .zshrc file.
now open .zrch file and add your path
CHROME_EXECUTABLE="/Applications/Vivaldi.app/Contents/MacOS/Vivaldi"
and restart your terminal and you are done.
in my case it was because the name of my chrome was "google chrome 2.app"
i renamed it to "google chrome.app"
You can also try with just chrome instead of google-chrome.

Mac Terminal - How to start Android Virtual Device Manager on CLI?

I am currently developing a mobile web application and I don't have a test device yet so I'm using the android-emulator to check the site. On my mac, I have installed the stand-alone Android SDK. Every time I want to use the AVD Manager, I have to execute the following on my terminal:
monitor
This command (being executed on the installed android sdk path) will open the Android Device Monitor and from here, I go to its menu bar and select Window Virtual Device Manager just to open the AVD Manager. So, is there a shortcut for that? I mean, i want to directly open the AVD manager via cli.
I was able to open it from terminal with:
android avd
You may need to navigate to your SDK tools/ first. Here is reference I used:
AVD Manager
Go to tools directory inside your android sdk like:
cd ~/Android/Sdk/tools
and enter run your avd as
./emulator -avd <your-avd>
You can find your avd name by running:
./emulator -list-avds
You can start emulator use terminal shell
emulator -avd <avd_name> [<options>]
options can be special -http-proxy, -dns-server setting. Get more options here
And to list all avd you can use:
emulator -list-avds
result like following:
4.7_WXGA_API_23
Nexus_5X_Edited_API_23
Example when I start Nexus_5X_Edited_API_23 emulator in OS X 10.11 with proxy setting
~/Library/Android/sdk/tools/emulator -netdelay none -netspeed full -avd Nexus_5X_Edited_API_23 -http-proxy http://username:password#local_server:8080
this is just a small addon to previous solutions presented. What is probably handy to do is to just jam this as a alias into your bash_profile like so:
Open your bash_profile:
nano ~/.bash_profile
Add this:
alias avd='cd /path-to-sdk/tools; ./android avd'
Source it again:
source ~/.bash_profile
In the CLI type:
avd
Now you can open up the AVD by just using avd in the command line. The only thing i haven't figured out how to make it stay alive after closing the terminal. Maybe somebody has tips on that.
Use the Android SDK Tools:
avdmanager
Or you can also start it by using the command below but it's deprecated though on newer version. Before executing it, make sure to export your Android SDK's tools directory in your ~/.bash_profile (i.e. export PATH="/Users/user/Software/android-sdk-macosx/tools:$PATH")
android avd
Old answer:
In order to open the avd manager on terminal, execute the following:
/usr/bin/java -Xmx256M -XstartOnFirstThread \
-Dcom.android.sdkmanager.toolsdir=/path/of/android-sdk-macosx/tools \
-classpath /path/of/android-sdk-macosx/tools/lib/sdkmanager.jar:/path/of/android-sdk-macosx/tools/lib/swtmenubar.jar:/path/of/android-sdk-macosx/tools/lib/x86_64/swt.jar \
com.android.sdkmanager.Main avd
emulator -avd <nameOfYourAvdEmulator>
Find the names of your emulators using avdmanager list avd:
avdmanager list avd
Name: Nexus_5X_API_23_Android_6.0
Device: Nexus 5X (Google)
Path: /Users/edward3/.android/avd/Nexus_5X_API_23_Android_6.0.avd
Target: Google APIs (Google Inc.)
Based on: Android 6.0 (Marshmallow) Tag/ABI: google_apis/x86
Skin: nexus_5x
Sdcard: 512M
Add to your ~/.profile if missing:
# Add to your ~/.profile PATH to easily run emulator and avdmanager commands
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
# Create alias to run your favorite Android emulator
alias avd-run='emulator -avd Nexus_5X_API_23_Android_6.0 &'
Open a new terminal or use source ~/.profile to reload changes made to your ~/.profile
Start your favorite emulator using the alias you created:
avd-run

Is it possible to run Chrome as an external tool on Eclipse 3.6 on Mac OS X?

I'm trying to set up Chrome to run as an external tool in Eclipse on the Mac. I've entered the path to Chrome as the Location variable:
"/Applications/Chrome.app/Contents/MacOS/Google\ Chrome"
I've got some arguments to pass in to Chrome, but that's not so important - I can't seem to get it started from Eclipse as an External Tool at all. The "Run" button is greyed out, and the configuration doesn't show up on the External Tools run menu once I save it. What am I doing wrong/missing?
UPDATED:
Attempting to use the "open" command ala Running external tools in Eclipse on Mac OS X appears to simply switch to a running instance of Chrome, instead of run chrome with me command line arguments.
I've tried location:
/usr/bin/open
Arguments:
-a "/Applications/Chrome.app" --args "localhost"
and Chrome does not open localhost - instead it simply switches to an existing open window with Chrome in it.
Does this similar SO post help you?
Running external tools in Eclipse on Mac OS X

Is there a way to add Google Chrome as an external web browser in Flash Builder Standalone for Mac?

It currently seems impossible to add Google Chrome as an external web browser in Flash Builder Standalone for Mac. In this context, Eclipse only cares about "Unix executables" and not .app files.
For example, the path to Firefox on a Mac is: /Applications/Firefox.app/Contents/MacOS/firefox-bin
which is only found by right-clicking and choosing 'Show Package Contents' on Firefox.app in your Applications directory.
If you try to add Google Chrome as a new external web browser, you'll have to repeat this process to navigate to /Applications/Google Chrome.app/Contents/MacOS where the 'Google Chrome' Unix exxecutable resides.
The problem is that space in the name. If you attempt to click OK in Eclipse, you'll get an error preventing you from continuing:
The location value is not a valid path
name
Are there any workarounds for this so I can use Chrome as my development browser only? I did some searching and all I could come up with was this:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=297273
UPDATE: A kind and savvy Flash Builder engineer gave me a helpful tip. Note that you'll need to show hidden files in Mac, by opening Terminal and entering the following command:
defaults write com.apple.finder AppleShowAllFiles TRUE
killall Finder
Press Return to relaunch Finder. Once hidden files are shown, "You’ll find what you need in [YOUR WORKSPACE]/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.browser.prefs.
There’s a 'browsers' property there that defines XML for defining Eclipse’s web browsers. Add a new browser location and name and restart Flash Builder."
In this case you'd add:
<external location\="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" name\="Google Chrome"/>\n
I can confirm that this works. Hopefully we won't have to resort to this kind of hackery on the next go around.
You can do this from the UI in FB 4.5 - However, you need this exact path (unquoted and unescaped) in Preferences->Web Browser. Select "Use External Browser" and add the line below as the location (You may not need the 'name\="Google Chrome" bit, but looks like it worked all in one line for me):
/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" name\="Google Chrome
You could create an executable here: /usr/local/bin/chrome with these contents:
#!/bin/sh
open -a 'Google Chrome' $1 &
And then ensure Chrome's Preferences settings for "Web Browser" are this for external web browser "Google Chrome":
Name: Google Chrome
Location: /usr/local/bin/chrome
Parameters: %URL%
Update
As of Eclipse 4.3.1, the script approach (below) no longer works, but the simpler option of simply selecting "Google Chrome.app" as an external browser (using Eclipse UI) is fixed.
Old (obsolete) answer
My workaround was to create a shell script that opens Chrome (see below), and point Eclipse to this script. In this way Chrome is opened with 2 tabs - the home page and the requested page - but this was good enough for me.
#! /bin/sh
open /Applications/Google\ Chrome.app $*
You need the path to the Unix Executable file of Google Chrome.
How to:
in Finder, right click Google Chrome.app "Show Package Content".
Navigate down to Content/MacOS
cmd + i and copy the path to the Unix Executable File
In Eclipse Preferences Web Browser / Location, "brows.."
Paste in the path to the Unix Executable.
The path, something like: /Applications/Google Chrome.app/Contents/MacOS
Location: /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
Parameters: -sandbox
The simplest way to get Flash Builder Standalone for Mac to recognize Chrome as the default system browser is
Open Safari
Go to menu Safari > Preference > General
Change 'Default web browser' : Safari
Change 'Default web browser' : Chrome
Close Safari
This solution is more general as it applies to any application which chooses the incorrect system browser. (thanks to Kelvin Lawrence at IBM)
For me worked with the following configuration:
Location: /usr/bin/open
Parameters: -a "Google Chrome.app" %URL%
I found the solution in a blog's post that doesn't exist anymore, it involves configuring the Location to be /usr/bin/open and the parameter is %URL%.
You need to make sure that google chrome is your default browser and it will work properly. This is the only method that worked for me on OSX Lion.
/Applications/Google\ Chrome.app/Contents/MacOS
escape the space in the path to the google chrome executable. OS X only cares about unix executables, because its posix based as well, it doesn't actually have much to do with eclipse.