2013-02-07 165 views
1

我目前正試圖將我的應用程序推送到Heroku。我已經能夠部署它幾次了,但現在我已經在我的packages.json文件中將貓鼬從「> = 3.5.0」更新爲「> = 3.6.0rc0」。但是,版本3.6需要mpath和mpromise。將Node.JS應用程序部署到Heroku - 緩存問題?

當slug編譯開始時,它使用緩存版本的mongoose或其他東西,因爲當我的應用程序啓動時,出現「Error:Can not find module'mpath'」。

我試圖建立一個自定義buildpack的Git,將停止緩存,我只是註釋掉緩存東西在斌/編譯,可在這裏:https://github.com/jValdron/heroku-buildpack-nodejs

這裏是推的輸出:http://pastebin.com/L3Yqy2NR

另外,當我從package.json中刪除了一些依賴項時,如果我使用'heroku run bash'登錄,我可以看到那些已經刪除了node_modules中的依賴項。我已經嘗試刪除node_modules文件夾並執行另一個'git push',但這也不起作用。而那些刪除的deps仍然在node_modules中。

任何人有關於如何解決這個問題的想法?

編輯:

這裏是我的package.json文件:

{ 
    "name": "souply-api", 
    "version": "0.1.0", 
    "author": "Jason Valdron <[email protected]>", 
    "description": "Main gears that runs the Soup.ly application", 
    "dependencies": { 
     "bcrypt": ">= 0.7.3", 
     "express": ">= 3.0.5", 
     "extend": ">= 1.1.3", 
     "imagemagick": ">= 0.1.3", 
     "jade": ">= 0.27.7", 
     "knox": ">= 0.4.6", 
     "less": ">= 1.3.1", 
     "less-middleware": ">= 0.1.9", 
     "moment": ">= 1.7.2", 
     "mongoose": ">= 3.6.0rc0", 
     "mongoose-types": ">= 1.0.3", 
     "node-native-zip": ">= 1.1.0", 
     "nodemailer": ">= 0.3.37", 
     "oauth2orize": ">= 0.1.0", 
     "passport": ">= 0.1.15", 
     "passport-local": ">= 0.1.6", 
     "passport-google": ">= 0.2.0", 
     "passport-facebook": ">= 0.1.4", 
     "passport-twitter": ">= 0.1.4", 
     "passport-http": ">= 0.2.1", 
     "passport-http-bearer": ">= 0.2.0", 
     "passport-oauth2-client-password": ">= 0.1.0", 
     "poor-form": ">= 1.1.3", 
     "request": ">= 2.12.0", 
     "socket.io": ">= 0.9.13" 
    }, 
    "engines": { 
     "node": "0.8.x", 
     "npm": "1.1.x" 
    } 
} 

貓鼬被設置爲3.6.0rc,如前面說。 Mpath是Mongoose的package.json文件中的一個依賴項。此外

"dependencies": { 
    "hooks": "0.2.1" 
    , "mongodb": "1.2.11" 
    , "ms": "0.1.0" 
    , "sliced": "0.0.3" 
    , "muri": "0.3.0" 
    , "mpromise": "0.2.0" 
    , "mpath": "0.1.1" 
} 

,如果我heroku run bash登錄,並導航到node_modules/mongoose/node_modules我看到的mpath和mpromise是不存在的:如果我看我的地方貓鼬的package.json文件,我可以看到這一點。

回答

4

node_modules在Git倉庫中。通過從回購中刪除它,它工作正常。

+0

你應該接受這個答案,因爲這樣:) :) – streetlight

+1

@streetlight啊,謝謝你,我回答了,必須等待幾個小時才能接受我自己的答案,我有點忘了它:) – jValdron

+0

沒問題 - 發生在我們最好的人身上! – streetlight

0

您將需要更新您的package.json是貓鼬的最新版本,您正在使用

您需要的mpath添加到您的package.json也

能(前貓鼬進入)你發佈你的package.json文件?

+0

見我的編輯。我也已經嘗試過包括mpath和mpromise(3.6.0rc0的2個新版本),但是這似乎也不起作用。 – jValdron

2

爲node_modules現在的Heroku支持禁用緩存:https://devcenter.heroku.com/articles/nodejs-support#cache-behavior

Heroku maintains a cache directory that is persisted between builds. This cache is used to store caches for npm, yarn, and bower. You can disable all caching for Node.js apps if you prefer:

heroku config:set NODE_MODULES_CACHE=false git commit -am 'disable node_modules cache' --allow-empty git push heroku master

0

node_modules的刪除緩存和重新部署:

git rm -r --cached node_modules 

然後git push heroku master

你也可以DIS能,如果你不想緩存node_module而重新部署緩存:

heroku config:set NODEMODULESCACHE=false 
git commit -am 'rebuild' --allow-empty 
git push heroku master 
heroku config:unset NODEMODULESCACHE 
0

中的package.json更改節點版本爲我做。

例如:

"engines": { 
    "node": "9.2.1" 
} 
相關問題