2015-03-19 95 views
3

我在我的流星項目中使用了momentjs:moment包。客戶端moment(new Date())通話效果很好。如果我在服務器端執行相同的調用,或者如果我在console.log(moment(new Date()));中包裝相同的調用,則會在此問題底部收到錯誤消息。Momentjs與流星似乎並沒有在服務器端工作

如果我運行meteor shell,然後moment(new Date());我也收到一個錯誤(moment is not defined)。但是,如果從外殼,我把它包裝在一個console.log(moment(new Date()));它工作正常,並打印出來的控制檯。

任何想法我忘記了什麼,或者我不在這裏做什麼?

W20150318-19:55:45.885(-5)? (STDERR) TypeError: Property 'moment' of object #<Object> is not a function 
    W20150318-19:55:45.885(-5)? (STDERR)  at Object._.extend.send_donation_email (app/server/methods/mandrill.js:37:25) 
    W20150318-19:55:45.885(-5)? (STDERR)  at Object.Stripe_Events.charge.succeeded (app/server/lib/stripe_events.js:55:23) 
    W20150318-19:55:45.885(-5)? (STDERR)  at [object Object].Router.route.where (app/both/router/router.js:238:48) 
    W20150318-19:55:45.885(-5)? (STDERR)  at boundNext (packages/iron:middleware-stack/lib/middleware_stack.js:251:1) 
    W20150318-19:55:45.885(-5)? (STDERR)  at runWithEnvironment (packages/meteor/dynamics_nodejs.js:108:1) 
    W20150318-19:55:45.885(-5)? (STDERR)  at packages/meteor/dynamics_nodejs.js:121:1 
    W20150318-19:55:45.885(-5)? (STDERR)  at [object Object].urlencodedParser (/Users/Bechard/.meteor/packages/iron_router/.1.0.7.1oysnq2++os+web.browser+web.cordova/npm/node_modules/body-parser/lib/types/urlencoded.js:69:27) 
    W20150318-19:55:45.885(-5)? (STDERR)  at packages/iron:router/lib/router.js:277:1 
    W20150318-19:55:45.885(-5)? (STDERR)  at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1) 
    W20150318-19:55:45.885(-5)? (STDERR)  at [object Object].hookWithOptions (packages/iron:router/lib/router.js:276:1) 
    W20150318-19:55:45.885(-5)? (STDERR)  at boundNext (packages/iron:middleware-stack/lib/middleware_stack.js:251:1) 
    W20150318-19:55:45.885(-5)? (STDERR)  at runWithEnvironment (packages/meteor/dynamics_nodejs.js:108:1) 

**更新:流星1.1仍然有這個問題。 **

我縮小了它似乎工作的原因,然後停止工作。如果我的應用程序遇到錯誤,而沒有捕獲它,那麼時刻就會停止工作。爲了測試這一點,我開始了流星,然後流星殼和瞬間(),它的工作。然後我得到我的應用程序調用一個不存在的函數,它總是拋出類似下面的錯誤。然後,我再次從Meteor Shell運行時刻(),此時刻()不起作用。如果我重新啓動流星,它仍然不起作用。我重新啓動了電腦,但仍然無法工作。

(STDERR) TypeError: Property 'customer.source.updated' of object #<Object> is not a function 
W20150401-13:46:11.812(-5)? (STDERR)  at [object Object].Router.route.where (app/both/router/router.js:254:48) 
W20150401-13:46:11.812(-5)? (STDERR)  at boundNext (packages/iron:middleware-stack/lib/middleware_stack.js:251:1) 
W20150401-13:46:11.812(-5)? (STDERR)  at runWithEnvironment (packages/meteor/dynamics_nodejs.js:108:1) 
W20150401-13:46:11.812(-5)? (STDERR)  at packages/meteor/dynamics_nodejs.js:121:1 
W20150401-13:46:11.812(-5)? (STDERR)  at [object Object].urlencodedParser (/Users/Bechard/.meteor/packages/iron_router/.1.0.7.1oysnq2++os+web.browser+web.cordova/npm/node_modules/body-parser/lib/types/urlencoded.js:69:27) 
W20150401-13:46:11.812(-5)? (STDERR)  at packages/iron:router/lib/router.js:277:1 
W20150401-13:46:11.812(-5)? (STDERR)  at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1) 
W20150401-13:46:11.812(-5)? (STDERR)  at [object Object].hookWithOptions (packages/iron:router/lib/router.js:276:1) 
W20150401-13:46:11.812(-5)? (STDERR)  at boundNext (packages/iron:middleware-stack/lib/middleware_stack.js:251:1) 
W20150401-13:46:11.813(-5)? (STDERR)  at runWithEnvironment (packages/meteor/dynamics_nodejs.js:108:1) 
+0

我沒有遇到'momentjs:moment'和1.0.4.1這個問題,但是我有時在改變'packages'文件中的包序列方面取得了成功。每個包應該聲明其依賴關係,但永遠不會少... – dalgard 2015-03-20 22:17:35

回答

3

我花了太長時間來處理今天的確切問題。我剛剛更新到流星1.0.4.1時,我遇到了這個問題(雖然對我來說,問題是時刻範圍無法找到moment爲了擴展它)。嘗試恢復到Meteor 1.0.3.2並查看問題是否仍然存在。

UPDATE:

我剛剛升級流星1.0.5,這個問題可能已經離開了我。如果您嘗試升級自己的應用,請在下面發帖,如果它也爲您解決問題。謝謝!

+0

是的,因爲這個包是直接集成到momentjs包我沒有看到在github上文件的問題。你試過還原嗎?我在我的系統中找到了一個解決方法,但最終我需要這個工作。謝謝 – JoshJoe 2015-03-19 19:53:37

+0

是的,我現在已經恢復到1.0.3.2。而且你是完全正確的,momentjs並沒有公開實際的流星包,這是屁股... – bengreene 2015-03-19 22:09:23

+1

實際上,他們似乎把他們的流星包裝到他們的核心repo中:https://github.com/moment/時刻/樹/發展/流星 - 所以我們應該在那裏解決他們的問題。 – bengreene 2015-03-19 22:10:57