how run "npm install" in node.js application?

i like this post (click again to cancel)
0
i dont like this post (click again to cancel)

hi, I'm using node.js.

I want to use external modules, so I created package.json file as following.

{"name":"foobar","version":"1.0.0","dependencies":{"express":"2.4.4"}}

then pushed application,

# upload /Users/sugyan/dotcloud/foobar ssh://dotcloud@uploader.dotcloud.com:21122/foobar
# rsync
Pseudo-terminal will not be allocated because stdin is not a terminal.
Warning: Permanently added '[uploader.dotcloud.com]:21122,[184.73.14.49]:21122' (RSA) to the list of known hosts.
building file list ... done
./
dotcloud.yml
foobarnode/
foobarnode/package.json
foobarnode/server.js
foobarnode/supervisord.conf

sent 689 bytes received 120 bytes 147.09 bytes/sec
total size is 377 speedup is 0.47
Deployment for "foobar" triggered. Will be available in a few seconds.
2011-08-08 02:02:51 [api] Waiting for the build. (It may take a few minutes)
2011-08-08 02:02:51 [www.0] Deploying...
2011-08-08 02:03:37 [www.0] Service booted
2011-08-08 02:03:37 [api] All the services are ready. Beginning the build.
2011-08-08 02:03:38 [www.0] The build started
2011-08-08 02:03:38 [www.0] Fetched code revision rsync-1312768970.22
2011-08-08 02:03:46 [www.0] foobar@1.0.0 ./node_modules/foobar
2011-08-08 02:03:46 [www.0] └── express@2.4.4
2011-08-08 02:03:51 [www.0] node: stopped
2011-08-08 02:03:51 [www.0] node: ERROR (abnormal termination)
2011-08-08 02:03:52 [www.0] The build finished successfully
2011-08-08 02:03:52 [api] Deploy finished

 

does "npm install foobar" run on "/home/dotcloud" ?

I want dotcloud server to install "express" module on /home/dotcloud/node_modules, but "foobar" (my application project) was installed as module package...

asked Aug 12 '11

sugyan gravatar image sugyan
1 1 1

6 Answers:

i like this answer (click again to cancel)
0
i dont like this answer (click again to cancel)

Well, it seems that express was installed correctly. Can you check the output of the node process, to make sure that another error is not hiding there? Feel free to specify the URL of your service if you want us to have a closer look!

link

answered Aug 08 '11

jpetazzo gravatar image jpetazzo
363 2 3 7
i like this answer (click again to cancel)
0
i dont like this answer (click again to cancel)

thanks! http://e231abb3.dotcloud.com/ now works!

but.. I created another new nodejs application, and push. It doesn't work. (the URL is http://38004db5.dotcloud.com/ )

ssh logged in and run "tree" command.

current
├── dotcloud.yml
├── hogefuganode
│   ├── package.json
│   ├── server.js
│   └── supervisord.conf
└── node_modules -> /home/dotcloud/node_modules/

2 directories, 4 files

 

was target dirctory to deploy changed?

link

answered Aug 10 '11

sugyan gravatar image sugyan
1 1 1
i like this answer (click again to cancel)
0
i dont like this answer (click again to cancel)

yes, express was installed correctory, but as dependency modules of "foobar"(name of project directory).

 

this is /var/log/supervisor/node-stderr--*.log:

node.js:134
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: Cannot find module 'express'
at Function._resolveFilename (module.js:317:11)
at Function._load (module.js:262:25)
at require (module.js:346:19)
at Object.<anonymous> (/home/dotcloud/rsync-1312847326.98/foobarnode/server.js:1:77)
at Module._compile (module.js:402:26)
at Object..js (module.js:408:10)
at Module.load (module.js:334:31)
at Function._load (module.js:293:12)
at Array.<anonymous> (module.js:421:10)
at EventEmitter._tickCallback (node.js:126:26)

 

"require" failed at "node server.js" process, because express is installed as foobar's dependency(not project dependency).

directory trees are:

.
├── code -> rsync-1312847326.98
├── current -> code/foobarnode
├── environment.json
├── node_modules
│   └── foobar
│   ├── node_modules
│   │   └── express
│   ├── package.json
│   ├── server.js
│   └── supervisord.conf
└── rsync-1312847326.98
├── dotcloud.yml
└── foobarnode
├── node_modules -> /home/dotcloud/node_modules/
├── package.json
├── server.js
└── supervisord.conf

 

this sample project is hosted at http://e231abb3.dotcloud.com/ now. thanks.

link

answered Aug 08 '11

sugyan gravatar image sugyan
1 1 1
i like this answer (click again to cancel)
0
i dont like this answer (click again to cancel)

We had a bug in the nodejs dependency installation process. We fixed it and pushed the new builder into production a few minutes ago. I triggered a rebuild of your service, and it looks like it works!

link

answered Aug 10 '11

jpetazzo gravatar image jpetazzo
363 2 3 7
i like this answer (click again to cancel)
0
i dont like this answer (click again to cancel)

Sorry — this was caused by a regression introduced by the previous fix. This will hopefully be fixed today.

link

answered Aug 11 '11

jpetazzo gravatar image jpetazzo
363 2 3 7
i like this answer (click again to cancel)
0
i dont like this answer (click again to cancel)

This problem seems to be fixed. now my applications works successfully. thanks!

link

answered Aug 12 '11

sugyan gravatar image sugyan
1 1 1

Your answer

Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
[hide preview]

Question tools

Tags:

Stats:

Asked: Aug 12 '11

Seen: 346 times

Last updated: Aug 08 '11

Powered by Askbot version 0.7.23

Copyright DotCloud, 2011. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.