Search code examples
meteoradditionlocalpackagepersist

Meteor app does not see local packages in second terminal


I've got a app called packagetester with a /packages directory, and a local package called lauffenp:notifications inside of the /packages directory.

Here is the packages file from packagetester.

meteor-base             # Packages every Meteor app needs to have
mobile-experience       # Packages for a great mobile UX
mongo                   # The database Meteor supports right now
blaze-html-templates    # Compile .html files into Meteor Blaze views
session                 # Client-side reactive dictionary for your app
jquery                  # Helpful client-side library
tracker                 # Meteor's client-side reactive programming  library

standard-minifiers      # JS/CSS minifiers run for production mode
es5-shim                # ECMAScript 5 compatibility for older browsers.
ecmascript              # Enable ECMAScript2015+ syntax in app code

autopublish             # Publish all data to the clients (for prototyping)
insecure                # Allow all DB writes from clients (for prototyping)

lauffenp:notifications

Now, if I run it in a single terminal using meteor, it works fine, it finds the package like it should and executes it.

However, if I open a second terminal and try to do the same thing, it can't find the package:

=> Started MongoDB.                           
=> Errors prevented startup:                  

   While selecting package versions:
   error: unknown package in top-level dependencies: lauffenp:notifications

Here is a screen capture of the app running on the left terminal and failing on the right terminal. screen capture of app running/not running in two terminal instances

If I exit the left terminal, it won't run and gives me the same error. I have to meteor remove and meteor add to somehow 'reset' packages and then I can run it on one terminal.

How can I get meteor to 'persist' a local package?


Solution

  • The error you get on the second terminal seems to be related to missing packages, but in fact it is due to the fact that you are trying to run multiple instances of the same application within the same directory.

    You cannot do that.

    While one instance tries to build the app into the .meteor/local directory the other races to clean and rebuild and one of the instances lose track of dependencies, hence the misleading error message.

    But if you check the previous warning on the other terminal, you'll see that the actual problem is multiple instances.

    Namely,

    • if there is something else listening on 3000, you must run meteor on another port
    • if you want to run two instances of the same app, you must create another copy of your app folder, run the second instance from that copied folder and set it to listen on another port