mikeal / node.couchapp.js

Utility for writing couchapps.
Apache License 2.0
406 stars 78 forks source link

Cannot find module error #51

Open iainsproat opened 12 years ago

iainsproat commented 12 years ago

I received a Cannot find module error when trying to use couchapp on Windows XP. I'm not sure whether this is an npm issue or whether it is node couchapp. I'm running node version 0.6.13 and npm version 1.1.9.

git clone https://github.com/mikeal/node.couchapp.js.git
cd node.couchapp.js

installed couchapp globally:

npm install -g

and installed couchapp locally:

cd ..
cd test
npm install ".\..\node.couchapp.js"

Then I created the most basic app.js file:

var couchapp = require('couchapp')
var ddoc = {_id:'_design/app', shows:{}, updates:{}, views:{}, lists:{}};
exports.app = ddoc;

And tried running

node couchapp <command> app.js http://address.to.couch/database

but unfortunately it failed to work for me. I received the following error:

node.js:201
        throw e; // process.nextTick error, or 'error' event on first tick
          ^
Error: Cannot find module '<path_to_directory>\test\couchapp'
    at Function._resolveFilename (module.js:332:11)
    at Function._load (module.js:279:25)
    at Array.0 (module.js:479:10)
    at EventEmitter._tickCallback (node.js:192:40)

Instead I managed to get it working with the following:

node "./node_modules/couchapp/bin.js" push app.js http://address.to.couch/database
netpoetica commented 12 years ago

I am recieving the same error:

Keith$ node app.js

module.js:340 throw err; ^ Error: Cannot find module 'couchapp' 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. (/Users/Keith/Sites/capptest/app.js:1:79) 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) Keith$ npm install npm ERR! install Couldn't read dependencies npm ERR! Error: ENOENT, open '/Users/Keith/Sites/capptest/package.json' npm ERR! If you need help, you may report this log at: npm ERR! http://github.com/isaacs/npm/issues npm ERR! or email it to: npm ERR! npm-@googlegroups.com

npm ERR! System Darwin 10.8.0 npm ERR! command "node" "/usr/local/bin/npm" "install" npm ERR! cwd /Users/Keith/Sites/capptest npm ERR! node -v v0.8.8 npm ERR! npm -v 1.1.59 npm ERR! path /Users/Keith/Sites/capptest/package.json npm ERR! code ENOENT npm ERR! errno 34 npm ERR! npm ERR! Additional logging details can be found in: npm ERR! /Users/Keith/Sites/capptest/npm-debug.log npm ERR! not ok code 0

Additionally, I receive this error when trying to use boilerplate:

Keith$ couchapp boiler capptest Could not create /Users/Keith/Sites/capptest

Despite saying it could not create it, it does, and all boilerplate files are there but do not run.

Some facts: I recently installed CouchDB from Apache and ran it and started using it, and I'm pretty sure it's still running on my MacOSX Snow Leopard system right now (I'm able to curl to it from the command line and access it at 127.0.0.1). I then installed node.couchapp.js using npm with -g and received some errors - same ones I'm getting now - so some research told me I should do it your way by cloning your repo - getting same errors.

Any ideas about what's causing all this ruckus?

netpoetica commented 12 years ago

My Solution

Firstly, I'd like to say that the #1 problem is that configuring DBs and servers is not my forte, and that's the first step of the problem.

Anyhow, if you type in Terminal or Windows equivalent

npm ls -g

See if you have a dependancy issue with the mime module. I did have this issue (https://github.com/mikeal/node.couchapp.js/issues/60) and I followed the path in bin/ and changed "mime" : "1.2.2" to "mime" : "*". I also performed and npm update and restarted my computer. After doing so, I was able to work with node.couchapp.js by doing the following:

  1. Start CouchDB Server.app manually. This isn't stated anywhere, so I assumed that the node module loaded CouchDB without me having to run it myself - apparently that isn't the case. Again, a more experienced user would probably know this, but I didn't. You can download it from Apache: http://couchdb.apache.org/
  2. DONT use the node command to run app.js. You are not using node server in this case, you are only using node on the client side. What you should do is start CouchDB, and then do the following:

    couchapp push http://127.0.0.1:5984/NameOfYourDatabase app.js

What this is doing is actually loading the application as JSON into CouchDB, and creating a bunch of JSON information that will let you serve your app up by going to localhost:5984/NameOfYourDatabase

NOTE: NameOfYourDatabase has to exist already. You can create a database with curl.

Hope that helps!

sasrat commented 11 years ago

make sure you are in the file directory.