2013-07-23 64 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

相关问题