可以使用Node而不是Meteor启动Meteor应用程序吗?

5
如何使用`node`而不是`meteor`启动Meteor应用程序。 我已经尝试过以下方法:
$ meteor create m;
m: created.

To run your new app:
  cd m
  meteor

$ cd m;

$ meteor;
[[[[[ c:\git\m ]]]]]

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

=> App running at: http://localhost:3000/
   Type Control-C twice to stop.

# OK! This works :O)

$ node .meteor\local\build\main.js;
module.js:338
    throw err;
          ^
Error: Cannot find module 'fibers'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:278:25)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (c:\git\m\.meteor\local\build\programs\server\boot.js:1:75)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)

$ node .meteor\local\build\main.js;

# OK! This does not work :O(

$ cd .meteor\local\build\;

$ npm install fibers;
$ npm install semver;
$ npm install source-map-support;
$ npm install underscore;

$ node main.js
$ c:\git\m\.meteor\local\build\node_modules\fibers\future.js:267
                                                throw(ex);
                                                      ^
Error: Must pass options.rootUrl or set ROOT_URL in the server environment
    at Object.Meteor.absoluteUrl (packages/meteor/url_common.js:21:1)
    at Object.WebAppInternals.generateBoilerplate (packages/webapp/webapp_server.js:543:1)
    at Object.main (packages/webapp/webapp_server.js:739:1)
    at c:\git\m\.meteor\local\build\programs\server\boot.js:255:27

$ set ROOT_URL=localhost:3000;

$ set ROOT_URL;
ROOT_URL=localhost:3000

$ node main.js
c:\git\m\.meteor\local\build\programs\server\boot.js:263
}).run();
   ^
TypeError: Cannot read property 'slice' of null
    at packages/meteor/url_server.js:11:1
    at c:\git\m\.meteor\local\build\programs\server\packages\meteor.js:1098:4
    at c:\git\m\.meteor\local\build\programs\server\packages\meteor.js:1240:3
    at c:\git\m\.meteor\local\build\programs\server\boot.js:222:10
    at Function._.each._.forEach (c:\git\m\.meteor\local\build\node_modules\underscore\underscore.js:153:9)
    at c:\git\m\.meteor\local\build\programs\server\boot.js:117:5

也许需要更多的配置?

4
在应用程序已经打包后,在生产环境中使用Node启动Meteor应用程序是很常见的做法。这是你感兴趣的内容吗? - David Weldon
是的,我知道,但尽可能以最少的后处理和预处理启动应用程序会更好吧?我们正在进行调试实验。因此,接近开发状态的状态将是完美的。 - Stephan Ahlf
每次启动Meteor时,它都会启动Node.js来运行。这是一个打包的问题。详见答案。 - Michael Cole
1个回答

1
你可以简单地使用Demeteorizer: 在Github上的Demeteorizer 安装后,使用NPM进入你的Meteor应用程序目录,像这样使用: demeteorizer --output [路径]
然后进入你在[path]参数中指定的路径,然后:
npm install

Meteor应用程序使用以下环境变量:

MONGO_URL='mongodb://user:password@host:port/databasename?autoReconnect=true'
ROOT_URL='http://example.com'
MAIL_URL='smtp://user:password@mailhost:port/' (可选)
PORT=8080 (可选,默认为80)
npm start

我非常推荐这个解决方案。它简单易用,完美运行且速度快。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接