第一个meteor程序

能亲手出一个可运行的项目,是对新手莫大的鼓舞,哪怕只是个hello world

一、打开cmd,工作目录进入到项目文件夹下,如:d:\project\meterolearn

二、新建项目:命令行下输入 meteor create MyFirstTest

该步骤要从网络下载templating-compiler,必须保证墙外网站的可访问,否则可能会无法下载。

本人用的免费vpn,速度好慢。

好久,终于完成了

Created a new Meteor app in 'MyFirstTest'.

To run your new app:
cd MyFirstTest
meteor npm install
meteor

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

meteor create --bare to create an empty app.
meteor create --full to create a scaffolded app.

网络墙的问题,下载过程中有可能会出错,并且国内还没有meteor的镜像可用,应该也是meteor在国内使用不多的主要原因。

三、这个是meteor自动生成的简单示例工程,下面运行起来看一看

1、cd myfirsttest进入项目所在目录

2、输入meteor启动服务

哈哈,竟然出错了,正好记录下来

E:\Project\meteor\MyFirstTest>meteor
[[[[[ ~\E\Project\meteor\MyFirstTest ]]]]]

=> Started proxy.
=> Started MongoDB.
W20170122-13:37:24.933(8)? (STDERR) E:\Project\meteor\MyFirstTest\.meteor\local\build\programs\server\boot.js:348
W20170122-13:37:25.062(8)? (STDERR) }).run();
W20170122-13:37:25.064(8)? (STDERR)    ^
W20170122-13:37:25.067(8)? (STDERR)
W20170122-13:37:25.069(8)? (STDERR) Error: The babel-runtime npm package could not be found in your node_modules
W20170122-13:37:25.073(8)? (STDERR) directory. Please run the following command to install it:
W20170122-13:37:25.075(8)? (STDERR)
W20170122-13:37:25.078(8)? (STDERR)   meteor npm install --save babel-runtime
W20170122-13:37:25.081(8)? (STDERR)
W20170122-13:37:25.083(8)? (STDERR)     at meteorInstall.node_modules.meteor.babel-runtime.babel-runtime.js (packages\babel-runtime.js:37:9)
W20170122-13:37:25.088(8)? (STDERR)     at fileEvaluate (packages\modules-runtime.js:188:9)
W20170122-13:37:25.091(8)? (STDERR)     at require (packages\modules-runtime.js:111:16)
W20170122-13:37:25.093(8)? (STDERR)     at packages\babel-runtime.js:139:15
W20170122-13:37:25.096(8)? (STDERR)     at packages\babel-runtime.js:150:3
W20170122-13:37:25.098(8)? (STDERR)     at E:\Project\meteor\MyFirstTest\.meteor\local\build\programs\server\boot.js:295:34
W20170122-13:37:25.103(8)? (STDERR)     at Array.forEach (native)
W20170122-13:37:25.107(8)? (STDERR)     at Function._.each._.forEach (C:\Users\Administrator\AppData\Local\.meteor\packages\meteor-tool\1.4.2_3\mt-os.windows.x86_32\dev_bundle\server-lib\node_modules\underscore\underscore.js:79:11)
W20170122-13:37:25.112(8)? (STDERR)     at E:\Project\meteor\MyFirstTest\.meteor\local\build\programs\server\boot.js:128:5
W20170122-13:37:25.120(8)? (STDERR)     at E:\Project\meteor\MyFirstTest\.meteor\local\build\programs\server\boot.js:344:5
=> Exited with code: 1
W20170122-13:37:28.358(8)? (STDERR) E:\Project\meteor\MyFirstTest\.meteor\local\build\programs\server\boot.js:348
W20170122-13:37:28.362(8)? (STDERR) }).run();
W20170122-13:37:28.365(8)? (STDERR)    ^
W20170122-13:37:28.368(8)? (STDERR)
W20170122-13:37:28.370(8)? (STDERR) Error: The babel-runtime npm package could not be found in your node_modules
W20170122-13:37:28.375(8)? (STDERR) directory. Please run the following command to install it:
W20170122-13:37:28.378(8)? (STDERR)
W20170122-13:37:28.380(8)? (STDERR)   meteor npm install --save babel-runtime
W20170122-13:37:28.384(8)? (STDERR)
W20170122-13:37:28.386(8)? (STDERR)     at meteorInstall.node_modules.meteor.babel-runtime.babel-runtime.js (packages\babel-runtime.js:37:9)
W20170122-13:37:28.392(8)? (STDERR)     at fileEvaluate (packages\modules-runtime.js:188:9)
W20170122-13:37:28.397(8)? (STDERR)     at require (packages\modules-runtime.js:111:16)
W20170122-13:37:28.401(8)? (STDERR)     at packages\babel-runtime.js:139:15
W20170122-13:37:28.404(8)? (STDERR)     at packages\babel-runtime.js:150:3
W20170122-13:37:28.407(8)? (STDERR)     at E:\Project\meteor\MyFirstTest\.meteor\local\build\programs\server\boot.js:295:34
W20170122-13:37:28.415(8)? (STDERR)     at Array.forEach (native)
W20170122-13:37:28.419(8)? (STDERR)     at Function._.each._.forEach (C:\Users\Administrator\AppData\Local\.meteor\packages\meteor-tool\1.4.2_3\mt-os.windows.x86_32\dev_bundle\server-lib\node_modules\underscore\underscore.js:79:11)
W20170122-13:37:28.424(8)? (STDERR)     at E:\Project\meteor\MyFirstTest\.meteor\local\build\programs\server\boot.js:128:5
W20170122-13:37:28.429(8)? (STDERR)     at E:\Project\meteor\MyFirstTest\.meteor\local\build\programs\server\boot.js:344:5
=> Exited with code: 1
W20170122-13:37:32.303(8)? (STDERR) E:\Project\meteor\MyFirstTest\.meteor\local\build\programs\server\boot.js:348
W20170122-13:37:32.308(8)? (STDERR) }).run();
W20170122-13:37:32.310(8)? (STDERR)    ^
W20170122-13:37:32.312(8)? (STDERR)
W20170122-13:37:32.314(8)? (STDERR) Error: The babel-runtime npm package could not be found in your node_modules
W20170122-13:37:32.317(8)? (STDERR) directory. Please run the following command to install it:
W20170122-13:37:32.320(8)? (STDERR)
W20170122-13:37:32.321(8)? (STDERR)   meteor npm install --save babel-runtime
W20170122-13:37:32.324(8)? (STDERR)
W20170122-13:37:32.326(8)? (STDERR)     at meteorInstall.node_modules.meteor.babel-runtime.babel-runtime.js (packages\babel-runtime.js:37:9)
W20170122-13:37:32.334(8)? (STDERR)     at fileEvaluate (packages\modules-runtime.js:188:9)
W20170122-13:37:32.339(8)? (STDERR)     at require (packages\modules-runtime.js:111:16)
W20170122-13:37:32.341(8)? (STDERR)     at packages\babel-runtime.js:139:15
W20170122-13:37:32.343(8)? (STDERR)     at packages\babel-runtime.js:150:3
W20170122-13:37:32.346(8)? (STDERR)     at E:\Project\meteor\MyFirstTest\.meteor\local\build\programs\server\boot.js:295:34
W20170122-13:37:32.351(8)? (STDERR)     at Array.forEach (native)
W20170122-13:37:32.354(8)? (STDERR)     at Function._.each._.forEach (C:\Users\Administrator\AppData\Local\.meteor\packages\meteor-tool\1.4.2_3\mt-os.windows.x86_32\dev_bundle\server-lib\node_modules\underscore\underscore.js:79:11)
W20170122-13:37:32.359(8)? (STDERR)     at E:\Project\meteor\MyFirstTest\.meteor\local\build\programs\server\boot.js:128:5
W20170122-13:37:32.366(8)? (STDERR)     at E:\Project\meteor\MyFirstTest\.meteor\local\build\programs\server\boot.js:344:5
=> Exited with code: 1
=> Your application is crashing. Waiting for file change.
View Code

错误原因是,项目下面缺一个node_modules文件夹,应该是网络原因造成的,把以前项目中的这个文件夹复制过来,再次运行meteor

E:\Project\meteor\MyFirstTest>meteor
[[[[[ ~\E\Project\meteor\MyFirstTest ]]]]]

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

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

成功。

四、查看效果

浏览器中输入http://localhost:3000/

应该能看到经典的Welcome to Meteor!页面。

就不贴图了。

posted @ 2017-01-22 14:02  wonderhow  阅读(1632)  评论(0编辑  收藏  举报