I want to run the most basic Meteor app via Node. I make the following, orderly;
- mkdir src && cd src
- meteor create sample_app
- npm install --production
- meteor build … --allow-superuser --directory
- cd …/bundle
- node --version
v4.6.1
- node main.js
But, it throws the following error;
module.js:327
throw err;
^
*Error: Cannot find module 'fibers’
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.
(/server/boot.js:1:75)
at Module._compile (module.js:409:26)
at Object.Module._extensions…js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)*
Why cannot I run the most basic Node app via those simple steps?
Thank you!
This may have something to do with the new architecture of the meteor bundle (the process which converts a Meteor app to a regular Node.js app).
In Meteor < 0.9 you had to run npm install at the root of the bundle to get npm modules installed, now you have to cd in programs/server first, as stated in the README :
This is a Meteor application bundle. It has only one external dependency:
Node.js 0.10.29 or newer. To run the application:
$ (cd programs/server && npm install)
$ export MONGO_URL='mongodb://user:password@host:port/databasename'
$ export ROOT_URL='http://example.com'
$ export MAIL_URL='smtp://user:password@mailhost:port/'
$ node main.js
Use the PORT environment variable to set the port where the
application will listen. The default is 80, but that will require
root on most systems.
Find out more about Meteor at meteor.com.
Modulus developed a tool called demeteorizer
which is supposed to automate this process of converting a Meteor app to a Node.js app, and it's possible that they have not yet modified the tool to account for 0.9 changes.
You simply need to
npm install
and possibly export environment variables first, depending on what you need in your application.
export MONGO_URL='mongodb:'mongodb://user:password@host:port/databasename'
...
After that you just run the bundled app with node
node main.js
I assume you have installed node js, pm2, mongodb and you have create a DBNAME, USER with USERNAME and PASSWORD.
After you create a meteor project.
- BUILD using command
meteor build --server-only .
- A tar file
xyz.tar.gz
will be created for you. Use command tar -xzf xyz.tar.gz
to untar it.
- Inside the folder goto
bundle/programs/server/
and then run command npm install --production
- Install pm2 node package.
- set mongo db properties as
export MONGO_URL=”mongodb://username:password@127.0.0.1:27017/dbName”;export ROOT_URL=”http://localhost/”;export PORT=3000
- Go back to
bundle/
directory and run pm2 using command pm2 start --name “UID” main.js
.
- To view if project is online and running use command
pm2 show 0