Can't create working meteor.js project on a va

2019-01-11 01:52发布

问题:

I cannot start up a new Meteor application on a Vagrant linux box (running on a Mac). It fails every time with a 'unspecified uncaught exception' in Mongo. I have tried a bunch of things to get this going, but even with the simplest set-up, I cannot get the project running. I would be grateful for any suggestions.

My steps are:

  1. create a completely clean Vagrant box ("ubuntu/trusty64");
  2. install Meteor on the new box (curl https://install.meteor.com/ | sh);
  3. choose a location to create the project;
  4. create a new Meteor project (meteor create app);
  5. start up the project (cd app; meteor)

I know that the permissions on the vagrant shared folder are quirky, so for step #3 above I have tried putting the project:

  1. in the shared guest/host folder, /vagrant,
  2. in a subdirectory of the Vagrant home folder (/home/vagrant),
  3. in a subdirectory of / (with permissions set to vagrant:vagrant), and
  4. in a subdirectory of / with permissions set to root:root, the project created with sudo meteor create app and run with sudo meteor

In all cases, I see this error:

=> Started proxy.
Unexpected mongo exit code 100. Restarting.
Unexpected mongo exit code 100. Restarting.
Unexpected mongo exit code 100. Restarting.
Can't start Mongo server.
MongoDB had an unspecified uncaught exception.
This can be caused by MongoDB being unable to write to a local database.
Check that you have permissions to write to .meteor/local. MongoDB does
not support filesystems like NFS that do not allow file locking.

I cannot tell if this is a Vagrant issue (though I think not, given what I've tried) or a Meteor issue, but I suspect it is Meteor (or one of its many dependencies). I doubt it is a permissions issue, since it failed when running as root. I've tried building meteor from scratch and the build fails and I've tried creating the project with --release 0.9.0 and --release 0.9.2-rc1 and the download is simply killed without explanation.

回答1:

(1) After step 2 'install Meteor on the new box (curl https://install.meteor.com/ | sh)'

user$ cd /vagrant
user:/vagrant$ meteor create myApp

You should see the myApp folder on your Mac host (the same folder for the vagrantfile)

(2) Insides the myApp folder, you will see the default .meteor folder, make a folder called local if it is no there

user:/vagrant$ cd myApp/.meteor
user:/vagrant/myApp/.meteor$ mkdir local

(3) Create the same folder structure in the /home/vagrant

user:/vagrant/myApp/.meteor$ cd ~
~$mkdir -p myApp/.meteor/local

(4) Link or mount the /vagrant/myApp/.meteor/local to /home/vagrant/myApp/.meteor/local

sudo mount --bind /home/vagrant/myApp/.meteor/local/ /vagrant/myApp/.meteor/local/

or make it permanently

echo “sudo mount --bind /home/vagrant/myApp/.meteor/local/ /vagrant/myApp/.meteor/local/” >> ~/.bashrc && source ~/.bashrc

(5) Now you can start the meteor

~$cd /vagrant/myApp
user:/vagrant/myApp$meteor

The reason why I mount the local folder rather than the <.meteor> folder is that you can still edit the files insides the <.meteor> folder on your Mac host. You can replace myApp with whatever name you want

Hope this help



回答2:

I'm working with a Windows host, but maybe this will apply to your situation as well.

The only folder which causes the issue is ./meteor/local. If you relocate this with a symlink to be outside of the shared /vagrant folder you should be able to run the meteor app okay.

But, to put a symlink in the shared folder you need to enable symlinks in the VM... which requires starting Vagrant as an admin.

I put together an Vagrantfile with some scripts and instructions here:

https://github.com/ElectronVector/vagrant-meteor



回答3:

I ran into similar issues trying to run meteor on windows. It seems that mongodb is not able to write in the /vagrant folder. I solved this by doing

sudo mount --bind /home/vagrant/meteorapp/.meteor/ /vagrant/meteorapp/.meteor/

(got that from https://gist.github.com/gabrielhpugliese/5855677)



回答4:

Here is an answer that solved my problem. Launching meteor project from a shared folder on Debian VMware virtual machine(running on a Windows).

The issue is that mongodb can't create data files inside a shared folder, so in this case just use an existing mongodb for meteor project:

export MONGO_URL=mongodb://localhost:27017/your_db


回答5:

Doing

vagrant reload --provision

solved my problem. I think the reason might be some files got corrupted or deleted.