SAFE Desktop App Tutorial

This refers to the tutorial https://hub.safedev.org/platform/nodejs/

I have been following this tutorial, but there is one section that I don’t understand. It’s this bit:

“In this tutorial we will be using the SAFE Browser package that is built to work with the mock network. So please go ahead and download the one corresponding for your platform, and unzip the package in your PC. Before we launch it let’s go ahead and set the NODE_ENV environment variable set to dev to have our browser to effectively use the native libraries for mock routing:
$ export NODE_ENV=dev
You can now launch the browser (make sure you launch it from the same console where you just set the NODE_ENV variable)”

I have downloaded and unzipped ‘safe-browser-mock-v0.10.2-win-x64’.

But now I am just guessing. Am I setting the environment variable using Git Bash? It doesn’t say.

If so do I right click on the ‘safe-browser-mock-v0.10.2-win-x64’ folder, select Git Bash here and run $ export NODE_ENV=dev? When I try this, I get no errors, but I don’t know if it has worked.

Then I have to “make sure you launch it from the same console where you just set the NODE_ENV variable”. How do I do that?

I am now stuck. Any ideas anyone?

Thanks in advance, Malcolm

I’m not familiar with git bash so can’t help with that atm, but the instructions in the tutorial assume you are starting the browser from the command line, not using a right-click. So that means that rather than ‘right-click’ you would:

  • download the browser
  • extract the files
  • make sure the browser file is executable. You don’t say what operating system you are using so I can’t give precise instructions for this or what follows…
  • open a terminal (ie command line).
  • to run the browser on Linux, if the browser executable file is safe_browser you would then type the following on the terminal command line:
NODE_ENV=dev ./safe_browser

Or as in the tutorial you can type:

export NODE_ENV=dev
./safe_browser

@DGeddes I think it would help if the tutorial showed this, or provided a direct link to instructions on how to download, install and then run the browser with NODE_ENV set.

You could try echo $NODE_ENV before starting up the browser from your terminal.
If dev is printed then the environment variable has been set correctly :slight_smile:

1 Like

I haven’t done the tutorial, but…
According to HowTo: Set an Environment Variable in Windows - Command Line and Registry - Dowd and Associates, it looks like ‘setx’ is how you set environment variables from the command line on Windows. You could also set it from GUI like How to Set the Path and Environment Variables in Windows. I think you’ll be fine if you set it via GUI then run the mock browser via double click.

Using Git Bash you’ve done it perfectly well. Git Bash is basically Unix/Linux. The ‘same console’ means launching the executable it from the same Git Bash window in this case:

$ export NODE_ENV=dev  # set the variable
$ "./SAFE Browser.exe" # or ./SAFE\ Browser.exe due to space

Make sure you’re in the same directory as the SAFE Browser executable.

2 Likes

Thank you for your prompt reply. I will try this and let you know how I get on.

1 Like

Yes, this works. Thanks.

Thanks for the links, I will have a read.

Thanks, this works.

In Windows Explorer I have right clicked on the directory that was unzipped from the Github download, and clicked on ‘Git Bash here’.

I have run $ export NODE_ENV=dev.

Then, as suggested by Lionel, I ran $ echo $NODE_ENV, which successfully returned ‘dev’.

I then ran “./SAFE Browser.exe” (with the space), which returned 'Opening beaker:shell-window
’ and the SAFE browser window opened.

I have now successfully set up an account and logged in.

Thanks for your help everyone.

6 Likes

Hi all,
The amazing @hunterlester updated the tutorial for us a wee while ago.
DG.

1 Like