2

I'm trying to deploy a node.js app, based on Deployd (deployd.com). When deploying by "af update myapp", I get the following error:

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)

So it seems that there is a problem with the Deployd module. I declared it in the package.json file:

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

I tried to install it by: npm install -d

Or: npm install deployd

But I get the same error. I don't understand why this module doesn't work on Appfog. It works locally·

Thanks.


The log (final part, which for me seems interesting) that I get when running sudo npm install deployd --save

In a subdirectory: npm http ... [and so on] 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)
user2047330
  • 119
  • 1
  • 9

3 Answers3

2

Try using the --save option of npm to insure the package.json file is correct and that the dependency is stored into the node_modules subfolder.

npm install deployd --save

After running that command in the app's root folder, your app folder should look like:

<app folder>/node_modules/deployd/ <tons of sub dependencies>
<app folder>/package.json
<app folder>/<and other app files>
Tim Santeford
  • 27,385
  • 16
  • 74
  • 101
  • That seems to work in my app's root directory, but it doesn't on my subdirectories. I execute the command and it doesn't give any error, but the folder node_modules doesn't appear (in the subdirectory). By the way, I can't execute that command without SUDO, could that be related with my problem? – user2047330 Jul 23 '13 at 22:38
  • You should only need to run that command from your app's root folder and SUDO should not be necessary. If you have to use SUDO then you may have a permissions problem with the folder. – Tim Santeford Jul 24 '13 at 06:08
  • My app looks like this, but it's impossible for me to run it without SUDO. – user2047330 Jul 24 '13 at 11:04
1

One of the main problems is when using npm, is that you install a package globally and hence always have access to it. However, in this case you need to upload the packages as well to appfog.

This is how you do it.

  1. Use cmd or terminal to go to your project root.
  2. Install all the modules that you are going to need, for example deployd or underscore for example via npm install <module> -d. This will install all your modules inside a new your current directory in a folder called node_modules. Upload everything including node_modules folder to appfog.
  3. If you have subdirectories, then you can do one of two things, you can change require statements to match the directory from the root, so if you have something like root > dir, then you will have to give these kinds or require statements, such as var deployd = require("./../deployd"). Or you can go into each sub directory and install the modules it needs.
Games Brainiac
  • 80,178
  • 33
  • 141
  • 199
  • I followed the steps that you suggested, but I get the same error. I noticed that when I typed "sudo npm install -d" in a subdirectory, the node_modules wasn't created, so I copypasted it from the root directory... – user2047330 Jul 23 '13 at 18:21
  • @user2047330: Then, I would need to look at your computer, because that is a problem indeed. Because if npm is not installing in root modules, then we have a problem. – Games Brainiac Jul 23 '13 at 19:33
  • When I execute the suggested commands, it seems to be all OK, since I get any error, and the terminal log looks like if it had been installed. But in the subdirectories, the node_modules folder doesn't appear. By the way, as I have commented below, I can't execute these commands without SUDO, is that related with the problem? I followed that guide (What, no sudo? http://foohack.com/2010/08/intro-to-npm/), but even introducing the command mentioned there, I can't execute the npm commands without SUDO – user2047330 Jul 23 '13 at 22:39
  • By the way, my app runs fine locally. I've added in the original question post the log that I get when executing npm install. – user2047330 Jul 23 '13 at 23:01
  • @user2047330: Will look into this when I get up. Too sleepy. – Games Brainiac Jul 23 '13 at 23:10
  • have you figured out what was the problem? – user2047330 Jul 26 '13 at 15:36
  • @user2047330: Hey, sorry for the late reply, but take a look @ this -> http://net.tutsplus.com/tutorials/javascript-ajax/going-live-with-node/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+nettuts+%28Nettuts%2B%29 – Games Brainiac Aug 03 '13 at 07:27
  • It seems interestig, but here the author describes the Appfog deployment as very easy, without issues... – user2047330 Aug 04 '13 at 23:50
1

npm shrinkwrap tells appfog about native dependencies. Also, try removing engine section. Those are not supported versions. I also like to add a scripts tag for start, but the default entry-point app.js should work without it.

For more info, see here: https://docs.appfog.com/languages/node

konsumer
  • 3,411
  • 1
  • 30
  • 31