2

我正在尝试基于 Deployd (deployd.com) 部署 node.js 应用程序。通过“af update myapp”部署时,出现以下错误:

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 install -d

或者: npm install 已部署

但我得到同样的错误。我不明白为什么这个模块不能在 Appfog 上运行。在本地工作·

谢谢。


运行 sudo npm install 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

> ws@0.4.27 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'
deployd@0.6.10 ../node_modules/deployd
├── opener@1.3.0
├── scrubber@0.0.0
├── keypress@0.1.0
├── validation@0.0.1
├── step@0.0.5
├── semver@1.1.4
├── cookies@0.3.6
├── debug@0.7.2
├── corser@1.1.2
├── commander@1.0.5
├── wrench@1.3.9
├── q@0.8.12
├── async@0.1.22
├── mkdirp@0.3.5
├── underscore@1.5.1
├── ejs@0.7.2 
├── shelljs@0.0.6pre2
├── doh@0.0.4 (ejs@0.8.4)
├── filed@0.1.0 (mime@1.2.9)
├── send@0.0.2 (fresh@0.1.0, range-parser@0.0.4, mime@1.2.6)
├── fstream@0.1.23 (inherits@1.0.0, graceful-fs@2.0.0, rimraf@2.2.2)
├── tar@0.1.17 (inherits@1.0.0, block-stream@0.0.6)
├── fstream-ignore@0.0.7 (inherits@2.0.0, minimatch@0.2.12)
├── mongodb@1.0.2 (bson@0.0.6)
├── http-proxy@0.8.1 (colors@0.6.0-1, pkginfo@0.2.3, optimist@0.2.8)
├── request@2.25.0 (forever-agent@0.5.0, aws-sign@0.3.0, json-stringify-safe@5.0.0, qs@0.6.5, tunnel-agent@0.3.0, oauth-sign@0.3.0, cookie-jar@0.3.0, node-uuid@1.4.0, mime@1.2.9, hawk@1.0.0, form-data@0.1.0, http-signature@0.10.0)
├── forever-monitor@1.1.0 (watch@0.5.1, pkginfo@0.3.0, minimatch@0.0.5, utile@0.1.7, ps-tree@0.0.3, broadway@0.2.7)
└── socket.io@0.9.16 (base64id@0.1.0, policyfile@0.0.4, redis@0.7.3, socket.io-client@0.9.16)
4

3 回答 3

2

尝试使用--savenpm 的选项来确保 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>
于 2013-07-23T20:37:19.583 回答
1

使用 , 时的主要问题之一是您全局npm安装了一个包,因此始终可以访问它。但是,在这种情况下,您还需要将包上传到 appfog。

这就是你的做法。

  1. 使用cmdterminal转到您的项目根目录。
  2. 安装您将需要的所有模块,例如deploydunderscore通过npm install <module> -d. 这会将所有模块安装在一个名为node_modules. 将包括文件夹在内的所有内容上传node_modules到 appfog。
  3. 如果你有子目录,那么你可以做两件事之一,你可以改变 require 语句以匹配根目录,所以如果你有类似的东西root > dir,那么你将不得不给出这些种类或require语句,例如var deployd = require("./../deployd"). 或者您可以进入每个子目录并安装它需要的模块。
于 2013-07-23T15:44:17.303 回答
1

npm shrinkwrap告诉 appfog 有关本机依赖项的信息。另外,尝试删除engine部分。这些不是受支持的版本。我也喜欢为 添加一个scripts标签start,但默认入口点app.js应该在没有它的情况下工作。

有关更多信息,请参见此处:https ://docs.appfog.com/languages/node

于 2013-11-07T17:11:07.897 回答