能親手出一個可運行的項目,是對新手莫大的鼓舞,哪怕只是個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.
錯誤原因是,項目下面缺一個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!頁面。
就不貼圖了。