DEV Community

Ricky Eckhardt
Ricky Eckhardt

Posted on

Get up and Running with Meteor in WSL2

Getting started with Meteor on Windows Subsystem Linux 2 (WSL2) is easy, but it requires a few departures from the Meteor Developers documentation.

Step 1:

On WSL2? Install the latest official Meteor release from your terminal:

curl https://install.meteor.com/ | sh
Enter fullscreen mode Exit fullscreen mode

Note: You may need to use the sudo command to install Meteor. If you do a prompt will pop up for you to enter your WSL2 root password.

If installed correctly you should see:

ricky@DESKTOP-ULOB7UG:~$ curl https://install.meteor.com/ | sh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  7915    0  7915    0     0  40589      0 --:--:-- --:--:-- --:--:-- 40589
Removing your existing Meteor installation.
Downloading Meteor distribution
######################################################################## 100.0%

Meteor 1.10.2 has been installed in your home directory (~/.meteor).
Writing a launcher script to /usr/local/bin/meteor for your convenience.
This may prompt for your password.
[sudo] password for ricky: 

To get started fast:

  $ meteor create ~/my_cool_app
  $ cd ~/my_cool_app
  $ meteor

Or see the docs at:

  docs.meteor.com

Deploy and host your app with Galaxy:

  www.meteor.com/hosting
Enter fullscreen mode Exit fullscreen mode

Step 2:

Now that the installation is complete we need to change an environment variable to prevent issues when running MondoDB.

To continue we need to vi and edit a file at:

.meteor/packages/meteor-tool/.1.10.2.121ry7f.gueme++os.linux.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.linux.x86_64/tools/packaging/catalog/catalog-remote.js
Enter fullscreen mode Exit fullscreen mode

Note: This file path will change depending on the version installed.

To do this run the following command after changing the path to match your home directory:

vi /home/ricky/.meteor/packages/meteor-tool/.1.10.2.121ry7f.gueme++os.linux.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.linux.x86_64/tools/packaging/catalog/catalog-remote.js
Enter fullscreen mode Exit fullscreen mode

If vi tells you [Permission Denied] simply back out of vi using :q and run the following command after changing it to match your home directory:

sudo vi /home/ricky/.meteor/packages/meteor-tool/.1.10.2.121ry7f.gueme++os.linux.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.linux.x86_64/tools/packaging/catalog/catalog-remote.js
Enter fullscreen mode Exit fullscreen mode

Once you have the file open we need to change the following code around line 31:

const JOURNAL_MODE = process.env.METEOR_SQLITE_JOURNAL_MODE || "WAL";
Enter fullscreen mode Exit fullscreen mode

To read:

const JOURNAL_MODE =
  process.env.METEOR_SQLITE_JOURNAL_MODE || "TRUNCATE";
Enter fullscreen mode Exit fullscreen mode

To do this using vi simply arrow up or down to the line and type :R to edit the line, once finished, hit ESC. Now exit vi using :wq to save and exit.

If you had to run sudo to edit the file you need to modify it's permissions.

To do this run the following command changing it's home directory to match yours:

chmod +rw  /home/ricky/.meteor/packages/meteor-tool/.1.10.2.121ry7f.gueme++os.linux.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.linux.x86_64/tools/packaging/catalog/catalog-remote.js
Enter fullscreen mode Exit fullscreen mode

Step 3:

You are ready to create your Meteor app!

To create a Meteor app run the following command:

meteor create ~/myapp
Enter fullscreen mode Exit fullscreen mode

This command creates a meteor app in the home directory of WSL2. Creating the application in the home directory avoids errors listed in the error section of this guide.

If your app was created successfully you should see:

ricky@DESKTOP-ULOB7UG:~$ meteor create ~/myapp
Created a new Meteor app in '/home/ricky/myapp'.

To run your new app:                          
  cd /home/ricky/myapp                        
  meteor                                      

If you are new to Meteor, try some of the learning resources here:
  https://www.meteor.com/tutorials            

When you’re ready to deploy and host your new Meteor application, check out Galaxy:
  https://www.meteor.com/hosting              

To start with a different app template, try one of the following:

  meteor create --bare       # to create an empty app
  meteor create --minimal    # to create an app with as few Meteor packages as possible
  meteor create --full       # to create a more complete scaffolded app
  meteor create --react      # to create a basic React-based app
  meteor create --typescript # to create an app using TypeScript and React
Enter fullscreen mode Exit fullscreen mode

Now you are ready to go with Meteor!

Step 4:

Let's finish up by ensuring everything is running correctly!

First let's start the Meteor server.

To start the server simply type the following:

cd myapp
meteor
Enter fullscreen mode Exit fullscreen mode

If started correctly you should see:

[[[[[ ~/myapp ]]]]]                           

=> Started proxy.                             
=> Started MongoDB.                           
=> Started your app.                          

=> App running at: http://localhost:3000/
Enter fullscreen mode Exit fullscreen mode

Alright, there is one more thing to check. We need to ensure that Meteor Mongo will start.

To do this open a second WSL2 window and run the following command in the directory you just created your app in.

meteor mongo
Enter fullscreen mode Exit fullscreen mode

If everything worked above you should see:

MongoDB shell version v4.2.5
connecting to: mongodb://127.0.0.1:3001/meteor?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("0a0211ad-c3d5-478f-8427-7f90d2f54cd4") }
MongoDB server version: 4.2.5
meteor:PRIMARY> 
Enter fullscreen mode Exit fullscreen mode

Congratulations you are up and running with Meteor in WSL2! If you've run into an error check below to see the cause.

Errors you may run into using WSL2:

Error From Creating an App in a Windows Directory

Error

User gets the following message after creating a Meteor project on a mounted Windows drive.

ricky@DESKTOP-ULOB7UG:/mnt/c/Meteor/todo$ meteor
[[[[[ /mnt/c/code/Meteor/todo ]]]]]           

=> Started proxy.                             
Unexpected mongo exit code null. Restarting.  
Unexpected mongo exit code null. Restarting.  
Unexpected mongo exit code null. Restarting.  
Can't start Mongo server.                     
ricky@DESKTOP-ULOB7UG:/mnt/c/Meteor/todo$
Enter fullscreen mode Exit fullscreen mode

Fix

A quick fix to this is to create your project within your home directory in WSL2.

In WSL2 run the following command to create a project in your home directory:

meteor create ~/todo 
Enter fullscreen mode Exit fullscreen mode

Error from not changing from WAL to Truncate

Error

Running the following command:

meteor mongo
Enter fullscreen mode Exit fullscreen mode

The user gets:

Error: SQLITE_PROTOCOL: locking protocol
Retrying after error Error: SQLITE_PROTOCOL: locking protocol
=> awaited here:
at Promise.await
(/home/ricky/.meteor/packages/meteor-tool/.1.10.2.121ry7f.gueme++os.linux.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.linux.x86_64/dev_bundle/lib/node_modules/meteor-promise/promise_server.js:60:12)
at Db._execute (/tools/packaging/catalog/catalog-remote.js:361:8)
at /tools/packaging/catalog/catalog-remote.js:150:10
at Db._retry (/tools/packaging/catalog/catalog-remote.js:162:16)
at new Db (/tools/packaging/catalog/catalog-remote.js:149:8)
at RemoteCatalog.initialize (/tools/packaging/catalog/catalog-remote.js:699:15)
at /tools/cli/main.js:875:20 {
errno: 15,
code: 'SQLITE_PROTOCOL'
Enter fullscreen mode Exit fullscreen mode

Fix

To correct this error edit the meteor/tools/packaging/catalog/catalog-remote.js using the steps above.

Notes:

Meteor Documentation
Notes on Moving Meteor Development to WSL Debian
Support "Bash on Windows" #154
TRUNCATE journal mode for packaging DB on Windows like file systems #9644

Top comments (2)

Collapse
 
adrianvilla1504 profile image
adrianvilla1504 • Edited

The tutorial works, but if any problem accessing to the catalog-remote.js file with the routes exists, you must check for the route until *meteor-tool folder *, locate on its path with cd /home/<your username>/.meteor/packages/meteor-tool/

Then type ls -al and enter:

Image description

Check the meteor version. If you have two versions of meteor installed you need to make the procedure for both, after that point you just need to find the version, copy the folder name and paste it after /meteor-tool/.

Example:

/home/<your username>/.meteor/packages/meteor-tool/.2.11.0.1n3mjr4.uxyr++os.linux.x86_64+web.browser+web.browser.legacy+web.cordova/

and after that just paste the rest of the route mt-os.linux.x86_64/tools/packaging/catalog/catalog-remote.js as:

/home/<your username>/.meteor/packages/meteor-tool/.2.11.0.1n3mjr4.uxyr++os.linux.x86_64+web.browser+web.browser.legacy+web.cordova/**mt-os.linux.x86_64/tools/packaging/catalog/catalog-remote.js**

Maybe this routes will work for meteor version 2.11.0 and 2.9.1:

sudo vi /home/<your username>/.meteor/packages/meteor-tool/.2.11.0.1n3mjr4.uxyr++os.linux.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.linux.x86_64/tools/packaging/catalog/catalog-remote.js
Enter fullscreen mode Exit fullscreen mode
chmod +rw  /home/<your username>/.meteor/packages/meteor-tool/.2.11.0.1n3mjr4.uxyr++os.linux.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.linux.x86_64/tools/packaging/catalog/catalog-remote.js
Enter fullscreen mode Exit fullscreen mode

//////////////////////////////////////////////////////////////////

sudo vi /home/<your username>/.meteor/packages/meteor-tool/.2.9.1.z800bc.e7cwa++os.linux.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.linux.x86_64/tools/packaging/catalog/catalog-remote.js
Enter fullscreen mode Exit fullscreen mode
chmod +rw  /home/<your username>/.meteor/packages/meteor-tool/.2.9.1.z800bc.e7cwa++os.linux.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.linux.x86_64/tools/packaging/catalog/catalog-remote.js
Enter fullscreen mode Exit fullscreen mode
Collapse
 
captainchainsaw profile image
CaptainChainsaw

Have you been able to create an Android app using Meteor on WSL? I've tries and the best I can get is my app installed but I can't even submit the login credentials. Doesn't connect and I have port 3000 open. If you have any ideas I'd love to hear them.