2013-07-23 107 views
2

我試圖部署基於Deployd(deployd.com)的node.js應用程序。當通過「af update myapp」進行部署時,出現以下錯誤:在Appfog上部署基於Deployd(deployd.com)的Node.js應用程序

Uploading Application: 
    Checking for available resources: OK 
    Processing resources: OK 
    Packing application: OK 
    Uploading (2K): OK 
Push Status: OK 
Stopping Application 'myapp': OK 
Staging Application 'myapp': OK            
Starting Application 'myapp': . 
Error: Application [myapp] failed to start, logs information below. 

====> /logs/staging.log <==== 

# Logfile created on 2013-07-23 15:18:29 +0000 by logger.rb/25413 
Skipping npm support: npm-shrinkwrap.json is not provided 

====> /logs/stderr.log <==== 


module.js:340 
    throw err; 
    ^
Error: Cannot find module 'deployd' 
    at Function.Module._resolveFilename (module.js:338:15) 
    at Function.Module._load (module.js:280:25) 
    at Module.require (module.js:362:17) 
    at require (module.js:378:17) 
    at Object.<anonymous> (/mnt/var/vcap.local/dea/apps/myapp-0-  cd2bdee578441089a86b3b0331a96cd5/app/index.js:1:77) 
    at Module._compile (module.js:449:26) 
    at Object.Module._extensions..js (module.js:467:10) 
    at Module.load (module.js:356:32) 
    at Function.Module._load (module.js:312:12) 
    at Module.runMain (module.js:492:10) 

因此,似乎Deployd模塊存在問題。我宣佈它在的package.json文件:

{ 
    "name": "myapp-test-deployd", 
    "version": "0.0.1", 
    "dependencies": { 
    "deployd": "0.6.10" 
    }, 
    "engines": { 
    "node": "0.10.x", 
    "npm": "1.2.x" 
    } 
} 

我試圖安裝它: NPM安裝-d

或者: NPM安裝deployd

,但我得到了同樣的錯誤。我不明白爲什麼這個模塊不適用於Appfog。它在本地工作·

謝謝。


日誌(最後一部分,這對我來說似乎是有趣的)運行 時須藤NPM安裝deployd --save

在子目錄中,我得到: NPM HTTP ...等等] NPM HTTP 304 https://registry.npmjs.org/stack-trace NPM HTTP 304 https://registry.npmjs.org/delayed-stream/0.0.5 NPM HTTP 304 https://registry.npmjs.org/ini NPM HTTP GET https://registry.npmjs.org/tinycolor NPM HTTP GET https://registry.npmjs.org/options NPM HTTP 304 https://registry.npmjs.org/tinycolor NPM HTTP 304 https://registry.npmjs.org/options

> [email protected] install /home/me/Development/myapp-deployd-test /node_modules/deployd/node_modules/socket.io/node_modules/socket.io- client/node_modules/ws 
> (node-gyp rebuild 2> builderror.log) || (exit 0) 

make: Entering directory `/home/me/Development/myapp-deployd-test/node_modules/deployd/node_modules/socket.io/node_modules/socket.io- client/node_modules/ws/build' 
    CXX(target) Release/obj.target/bufferutil/src/bufferutil.o 
    SOLINK_MODULE(target) Release/obj.target/bufferutil.node 
    SOLINK_MODULE(target) Release/obj.target/bufferutil.node: Finished 
    COPY Release/bufferutil.node 
    CXX(target) Release/obj.target/validation/src/validation.o 
    SOLINK_MODULE(target) Release/obj.target/validation.node 
    SOLINK_MODULE(target) Release/obj.target/validation.node: Finished 
    COPY Release/validation.node 
make: Leaving directory `/home/me/Development/myapp-deployd-test/node_modules/deployd/node_modules/socket.io/node_modules/socket.io-client/node_modules/ws/build' 
[email protected] ../node_modules/deployd 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] ([email protected]) 
├── [email protected] ([email protected]) 
├── [email protected] ([email protected], [email protected], [email protected]) 
├── [email protected] ([email protected], [email protected], [email protected]) 
├── [email protected] ([email protected], [email protected]) 
├── [email protected] ([email protected], [email protected]) 
├── [email protected] ([email protected]) 
├── [email protected] ([email protected], [email protected], [email protected]) 
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]) 
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected]) 
└── [email protected] ([email protected], [email protected], [email protected], [email protected]) 

回答

1

一個主要的問題,使用npm時,就是你安裝一個軟件包全球,因此總能獲得它。但是,在這種情況下,您還需要將程序包上傳到appfog。

這是你如何做到的。

  1. 使用cmdterminal轉到您的項目根目錄。
  2. 安裝您將需要的所有模塊,例如deploydunderscore,例如通過npm install <module> -d。這會將所有模塊安裝在當前目錄中的新文件夾node_modules中。將包括node_modules文件夾在內的所有文件上傳到appfog。
  3. 如果你有子目錄,那麼你可以做兩件事情之一,你可以改變需要聲明的目錄從根相匹配,因此,如果您有類似root > dir,那麼你將不得不放棄這類或require陳述,如var deployd = require("./../deployd")。或者你可以進入每個子目錄並安裝它需要的模塊。
+0

我遵循了你建議的步驟,但我得到了同樣的錯誤。我注意到,當我在子目錄中輸入「sudo npm install -d」時,node_modules沒有創建,所以我從根目錄拷貝了它... – user2047330

+0

@ user2047330:然後,我需要看看你的電腦,因爲這確實是一個問題。因爲如果npm不在根模塊中安裝,那麼我們有問題。 –

+0

當我執行建議的命令時,它似乎一切正常,因爲我得到任何錯誤,並且終端日誌看起來像是否已安裝。但在子目錄中,node_modules文件夾不出現。順便說一下,正如我在下面評論的那樣,如果沒有SUDO,我不能執行這些命令,是否與問題有關?我遵循該指南(什麼,沒有sudo?http://foohack.com/2010/08/intro-to-npm/),但即使介紹了那裏提到的命令,我不能執行npm命令沒有SUDO – user2047330

2

嘗試使用NPM的--save選項,以確保文件的package.json是正確的,依賴存儲到node_modules子文件夾。

npm install deployd --save 

運行的應用程序的根文件夾命令後,您的應用程序文件夾應該是這樣的:

<app folder>/node_modules/deployd/ <tons of sub dependencies> 
<app folder>/package.json 
<app folder>/<and other app files> 
+0

這似乎在我的應用的根目錄中工作,但它不在我的子目錄中。我執行這個命令並且沒有給出任何錯誤,但是文件夾node_modules沒有出現(在子目錄中)。順便說一下,如果沒有SUDO我不能執行這個命令,這可能與我的問題有關嗎? – user2047330

+0

您應該只需要從應用程序的根文件夾運行該命令,並且不應該需要SUDO。如果您必須使用SUDO,那麼您可能對該文件夾有權限問題。 –

+0

我的應用程序看起來像這樣,但是我不可能在沒有SUDO的情況下運行它。 – user2047330

1

npm shrinkwrap告訴appfog有關本機的依賴。另外,請嘗試刪除engine部分。這些不是受支持的版本。我還想爲start添加scripts標記,但默認入口點app.js應該在沒有它的情況下運行。

欲瞭解更多信息,請看這裏:https://docs.appfog.com/languages/node

相關問題