mauricemach / zappa

Node development for the lazy.
zappajs.org
MIT License
949 stars 81 forks source link

Could not find module 'zappa' #27

Closed xaviershay closed 13 years ago

xaviershay commented 13 years ago

I can't seem to get this to work. Seems like I'm missing something obvious. Suggestions?

$ zappa cuppa.coffee
Error: Cannot find module 'zappa'
    at loadModule (node.js:275:15)
    at require (node.js:411:14)
    at Object.<anonymous> (/usr/local/lib/node/.npm/zappa/0.1.4/package/bin/zappa.coffee:9:11)
    at Object.<anonymous> (/usr/local/lib/node/.npm/zappa/0.1.4/package/bin/zappa.coffee:139:4)

$ npm --version           
0.2.7-3
$ coffee --version        
CoffeeScript version 1.0.0
$ node --version          
v0.2.6
thomasmaas commented 13 years ago

experiencing the same error

$ node -v
v0.2.6 $ npm -v
0.2.14-3 $ coffee -v CoffeeScript version 1.0.0

mauricemach commented 13 years ago

Couldn't reproduce it here... but it seems zappa's binary is on the path but the package is not properly installed. What's the output of npm ls zappa active?

xaviershay commented 13 years ago
$ npm ls zappa active                                                                                                           ~
npm info it worked if it ends with ok
npm info using npm@0.2.7-3
npm info using node@v0.2.6
zappa@0.1.4   =mauricemach active installed latest remote
npm ok
thomasmaas commented 13 years ago

idem with npm@0.2.14-3

mauricemach commented 13 years ago

I'm actually having the same problem now but with connect and express instead. Opened an issue on npm.

To confirm it's the same thing, when you ls /usr/local/lib/node/zappa do you see a package.json.js alone?

xaviershay commented 13 years ago
$ ls /usr/local/lib/node/zappa 
index.js    zappa.js
thomasmaas commented 13 years ago

yes i do: package.json.js, so that might be related to npm@0.2.14-3

jmreidy commented 13 years ago

I had this issue myself, but it's not a bug! Just add NODE_PATH to your env config. export NODE_PATH=/usr/local/lib/node/ Without setting the node path, coffeescript attempts to interpret zappa without the node context, which means all the requires can't resolve.

steeleforge commented 13 years ago

Experiencing something similar when attempting to install the 'edge' zappa to allow me to use connect@0.5.5

npm@0.3.0-8 node@v0.4.0 coffee-script@1.0.1 zappa@0.1.4

$ zappa cuppa.coffee Error: Cannot find module 'zappa' at Function._resolveFilename (module.js:289:11) at Function._load (module.js:241:25) at require (module.js:317:19) at Object. (/usr/local/lib/node/.npm/zappa/0.1.4/package/bin/zappa.coffee:9:11) at Object. (/usr/local/lib/node/.npm/zappa/0.1.4/package/bin/zappa.coffee:139:4) at Module._compile (module.js:373:26) at Object.run (/usr/local/lib/node/.npm/coffee-script/1.0.1/package/lib/coffee-script.js:55:19) at /usr/local/lib/node/.npm/coffee-script/1.0.1/package/lib/command.js:115:29 at /usr/local/lib/node/.npm/coffee-script/1.0.1/package/lib/command.js:85:26 at [object Object]. (fs.js:86:5)

esamattis commented 13 years ago

I seem to have this issue with the latest npm.

epeli@kamino ~
$ node --version
v0.4.1

epeli@kamino ~
$ npm --version
0.3.7

epeli@kamino ~
$ npm ls zappa active
npm info it worked if it ends with ok
npm info using npm@0.3.7
npm info using node@v0.4.1
zappa@0.1.4   =mauricemach active installed latest remote   Web development, cut-the-crap style.     framework websockets co
npm ok

epeli@kamino ~
$ zappa
Error: Cannot find module 'zappa'
    at Function._resolveFilename (module.js:290:11)
    at Function._load (module.js:242:25)
    at require (module.js:318:19)
    at Object.<anonymous> (/home/epeli/usr/lib/node/.npm/zappa/0.1.4/package/bin/zappa.coffee:9:11)
    at Object.<anonymous> (/home/epeli/usr/lib/node/.npm/zappa/0.1.4/package/bin/zappa.coffee:139:4)
    at Module._compile (module.js:374:26)
    at Object.run (/home/epeli/usr/lib/node/.npm/coffee-script/1.0.1/package/lib/coffee-script.js:55:19)
    at /home/epeli/usr/lib/node/.npm/coffee-script/1.0.1/package/lib/command.js:115:29
    at /home/epeli/usr/lib/node/.npm/coffee-script/1.0.1/package/lib/command.js:85:26
    at [object Object].<anonymous> (fs.js:86:5)

Setting the NODE_PATH doesn't seem to help

$ NODE_PATH=/home/epeli/usr/lib/node/ zappa
Error: Cannot find module 'zappa'
...
esamattis commented 13 years ago

Hmm, npm's changelog states following on 0.3.0

Packages without "main" modules don't export modules.

I don't see main in package.json of Zappa.

behrang commented 13 years ago

I have this problem too.

$ npm ls zappa active
npm info it worked if it ends with ok
npm info using npm@0.3.3
npm info using node@v0.4.0
zappa@0.1.4   =mauricemach active installed latest remote   Web development, cut-the-crap style.     framework websockets coffeescript
npm ok
esamattis commented 13 years ago

I fixed this in my fork.

https://github.com/epeli/zappa/commit/69a7f52b4a4fb567635745774ee9c975620961f7

But note that there are some extra stuff too

https://github.com/mauricemach/zappa/pull/30

behrang commented 13 years ago

I applied the change in epeli's fork. However I now get this:

Error: Cannot find module 'coffee-script/optparse'
at Function._resolveFilename (module.js:289:11)
at Function._load (module.js:241:25)
at require (module.js:317:19)
at Object.<anonymous> (/usr/local/lib/node/.npm/zappa/0.1.4/package/bin/zappa.coffee:16:18)
at Object.<anonymous> (/usr/local/lib/node/.npm/zappa/0.1.4/package/bin/zappa.coffee:139:4)
at Module._compile (module.js:373:26)
at Object.run (/usr/local/lib/node/.npm/coffee-script/1.0.1/package/lib/coffee-script.js:55:19)
at /usr/local/lib/node/.npm/coffee-script/1.0.1/package/lib/command.js:115:29
at /usr/local/lib/node/.npm/coffee-script/1.0.1/package/lib/command.js:85:26
at [object Object].<anonymous> (fs.js:86:5)
esamattis commented 13 years ago

Too old CoffeeScript?

behrang commented 13 years ago

No, CoffeeScript 1.0.1.

volpe commented 13 years ago

Just install node fresh, and zappa doesn't work:

% nvm install v0.4.1
% npm install zappa
% zappa
Error: Cannot find module 'zappa'
at Function._resolveFilename (module.js:290:11)
at Function._load (module.js:242:25)
at require (module.js:318:19)
at Object.<anonymous> (/Users/paul/.nvm/v0.4.1/lib/node/.npm/zappa/0.1.4/package/bin/zappa.coffee:9:11)
at Object.<anonymous> (/Users/paul/.nvm/v0.4.1/lib/node/.npm/zappa/0.1.4/package/bin/zappa.coffee:139:4)
at Module._compile (module.js:374:26)
at Object.run (/Users/paul/.nvm/v0.4.1/lib/node/.npm/coffee-script/1.0.1/package/lib/coffee-script.js:55:19)
at /Users/paul/.nvm/v0.4.1/lib/node/.npm/coffee-script/1.0.1/package/lib/command.js:115:29
at /Users/paul/.nvm/v0.4.1/lib/node/.npm/coffee-script/1.0.1/package/lib/command.js:85:26
at [object Object].<anonymous> (fs.js:86:5)

If I apply epeli patch I end up with the exact same issue as mentioned by Behrang.
Culprit is zappo/bin/zappo.coffee:10 {OptionParser} = require 'coffee-script/optparse'

It can't import OptionParser like that... (I'm too new to node to know how to do it correctly).

Any suggestions for a work around?

kowal commented 13 years ago

Same situation here..

$npm -v
0.3.12
$ node -v
v0.5.0-pre
$ coffee -v
CoffeeScript version 1.0.1

$ zappa server.coffee
Error: Cannot find module 'zappa'
at Function._resolveFilename (module.js:296:11)
at Function._load (module.js:242:25)
at require (module.js:324:19)
at Object.<anonymous>     (/usr/local/lib/node/.npm/zappa/0.1.4/package/bin/zappa.coffee:9:11)
at Object.<anonymous> (/usr/local/lib/node/.npm/zappa/0.1.4/package/bin/zappa.coffee:139:4)
at Module._compile (module.js:380:26)
at Object.run (/usr/local/lib/node/.npm/coffee-script/1.0.1/package/lib/coffee-script.js:55:19)
at /usr/local/lib/node/.npm/coffee-script/1.0.1/package/lib/command.js:115:29
at /usr/local/lib/node/.npm/coffee-script/1.0.1/package/lib/command.js:85:26
at [object Object].<anonymous> (fs.js:86:5)
digitarald commented 13 years ago

++ Same versions and trace

anair commented 13 years ago

Same error..

$ npm -v
0.3.15

$ node -v
v0.5.0-pre

$ coffee -v
CoffeeScript version 1.0.1

$ zappa cuppa.coffee

Error: Cannot find module 'zappa' at Function._resolveFilename (module.js:296:11) at Function._load (module.js:242:25) at require (module.js:324:19) at Object. (/usr/local/lib/node/.npm/zappa/0.1.4/package/bin/zappa.coffee:9:11) at Object. (/usr/local/lib/node/.npm/zappa/0.1.4/package/bin/zappa.coffee:139:4) at Module._compile (module.js:380:26) at Object.run (/usr/local/lib/node/.npm/coffee-script/1.0.1/package/lib/coffee-script.js:55:19) at /usr/local/lib/node/.npm/coffee-script/1.0.1/package/lib/command.js:115:29 at /usr/local/lib/node/.npm/coffee-script/1.0.1/package/lib/command.js:85:26 at [object Object]. (fs.js:86:5)

p3k commented 13 years ago

Chiming in:

$ npm -v

0.3.9

$ node -v

v0.4.1

$ coffee -v

CoffeeScript version 1.0.1

$ zappa cuppa.coffee

Error: Cannot find module 'zappa' at Function._resolveFilename (module.js:290:11) at Function._load (module.js:242:25) at require (module.js:318:19) at Object. (/home/node/.node_libraries/.npm/zappa/0.1.4/package/bin/zappa.coffee:9:11) at Object. (/home/node/.node_libraries/.npm/zappa/0.1.4/package/bin/zappa.coffee:139:4) at Module._compile (module.js:374:26) at Object.run (/home/node/.node_libraries/.npm/coffee-script/1.0.1/package/lib/coffee-script.js:55:19) at /home/node/.node_libraries/.npm/coffee-script/1.0.1/package/lib/command.js:115:29 at /home/node/.node_libraries/.npm/coffee-script/1.0.1/package/lib/command.js:85:26 at [object Object]. (fs.js:86:5)

volpe commented 13 years ago

You have a pull request (from nsyee) pending that fixes this... Care to accept it?

strathmeyer commented 13 years ago

Everyone please vote this issue up! Adding my +1 to the list...

$ npm install zappa
npm info it worked if it ends with ok
npm info using npm@0.3.17
npm info using node@v0.4.2
npm info preinstall zappa@0.1.4
npm info install zappa@0.1.4
npm info postinstall zappa@0.1.4
npm info predeactivate zappa@0.1.4
npm info deactivate zappa@0.1.4
npm info postdeactivate zappa@0.1.4
npm info preactivate zappa@0.1.4
npm info activate zappa@0.1.4
npm info postactivate zappa@0.1.4
npm info build Success: zappa@0.1.4
npm ok
$ export NODE_PATH=/usr/local/lib/node/
$ zappa
Error: Cannot find module 'zappa'
    at Function._resolveFilename (module.js:299:11)
    at Function._load (module.js:245:25)
    at require (module.js:327:19)
    at Object. (/usr/local/lib/node/.npm/zappa/0.1.4/package/bin/zappa.coffee:9:11)
    at Object. (/usr/local/lib/node/.npm/zappa/0.1.4/package/bin/zappa.coffee:139:4)
    at Module._compile (module.js:383:26)
    at Object.run (/usr/local/lib/node/.npm/coffee-script/1.0.1/package/lib/coffee-script.js:55:19)
    at /usr/local/lib/node/.npm/coffee-script/1.0.1/package/lib/command.js:115:29
    at /usr/local/lib/node/.npm/coffee-script/1.0.1/package/lib/command.js:85:26
    at [object Object]. (fs.js:86:5)
givankin commented 13 years ago

the same issue. manually attached changes from nsyee's pull request & now it works

Eirikur commented 13 years ago

Looks like I have the same problem:

eh@Dragon:~/coffee$ npm -v 0.3.17 eh@Dragon:~/coffee$ node -v v0.5.0-pre eh@Dragon:~/coffee$ zappa cuppa.coffee Error: Cannot find module 'zappa' at Function._resolveFilename (module.js:296:11) at Function._load (module.js:242:25) at require (module.js:324:19) at Object. (/home/eh/local/.node_libraries/.npm/zappa/0.1.4/package/bin/zappa.coffee:9:11) at Object. (/home/eh/local/.node_libraries/.npm/zappa/0.1.4/package/bin/zappa.coffee:139:4) at Module._compile (module.js:380:26) at Object.run (/home/eh/local/.node_libraries/.npm/coffee-script/1.0.1/package/lib/coffee-script.js:55:19) at /home/eh/local/.node_libraries/.npm/coffee-script/1.0.1/package/lib/command.js:115:29 at /home/eh/local/.node_libraries/.npm/coffee-script/1.0.1/package/lib/command.js:85:26 at [object Object]. (fs.js:86:5)

r-moeritz commented 13 years ago
nodejs@nodejs:~$ node -v
v0.5.0-pre
nodejs@nodejs:~$ npm -v
1.0.1rc5
nodejs@nodejs:~$ npm install coffee-script
coffee-script@1.0.1 ./node_modules/coffee-script
nodejs@nodejs:~$ cd node_modules/
nodejs@nodejs:~/node_modules$ git clone https://github.com/mauricemach/zappa.git zappa
Initialized empty Git repository in /home/nodejs/node_modules/zappa/.git/
remote: Counting objects: 319, done.
remote: Compressing objects: 100% (174/174), done.
remote: Total 319 (delta 169), reused 206 (delta 115)
Receiving objects: 100% (319/319), 78.53 KiB | 34 KiB/s, done.
Resolving deltas: 100% (169/169), done.
nodejs@nodejs:~/node_modules$ cd zappa/
nodejs@nodejs:~/node_modules/zappa$ sudo npm link
[sudo] password for nodejs:
/usr/local/bin/zappa -> /usr/local/lib/node_modules/zappa/bin/zappa.coffee
/usr/local/lib/node_modules/zappa@ -> /home/nodejs/node_modules/zappa
nodejs@nodejs:~/node_modules/zappa$ npm install
coffee-script@1.0.1 ./node_modules/coffee-script
socket.io@0.6.17 ./node_modules/socket.io
coffee-script@1.0.1 ./node_modules/coffeekup/node_modules/coffee-script
htmlparser@1.7.3 ./node_modules/jquery/node_modules/htmlparser
coffeekup@0.2.2 ./node_modules/coffeekup
mime@1.2.1 ./node_modules/express/node_modules/mime
qs@0.0.7 ./node_modules/express/node_modules/qs
mjsunit.runner@0.1.3 ./node_modules/jquery/node_modules/jsdom/node_modules/mjsunit.runner
request@1.9.5 ./node_modules/jquery/node_modules/jsdom/node_modules/request
jsdom@0.1.20 ./node_modules/jquery/node_modules/jsdom
jquery@1.5.1 ./node_modules/jquery
mime@1.2.1 ./node_modules/express/node_modules/connect/node_modules/mime
qs@0.0.7 ./node_modules/express/node_modules/connect/node_modules/qs
connect@1.2.3 ./node_modules/express/node_modules/connect
express@2.2.1 ./node_modules/express
nodejs@nodejs:~/node_modules/zappa$ cd examples/
nodejs@nodejs:~/node_modules/zappa/examples$ zappa hi.coffee
App "default" listening on *:5678...
LeifW commented 13 years ago

Same error: node -v v0.4.5

npm -v 1.0.1rc6

zappa
Error: Cannot find module 'zappa' at Function._resolveFilename (module.js:320:11) at Function._load (module.js:266:25) at require (module.js:348:19) at Object. (/usr/lib/node_modules/zappa/bin/zappa.coffee:9:11) at Object. (/usr/lib/node_modules/zappa/bin/zappa.coffee:139:4) at Module._compile (module.js:404:26) at Object.run (/usr/lib/node_modules/coffee-script/lib/coffee-script.js:55:19) at /usr/lib/node_modules/coffee-script/lib/command.js:115:29 at /usr/lib/node_modules/coffee-script/lib/command.js:85:26 at [object Object]. (fs.js:107:5)

kozmikyak commented 13 years ago

I got it working with the latest node and npm. Granted, I'm just starting with this stuff, and the above posts pointed me the right way.

First of all, the lib: key in package.json is no longer being exported. Second of all, a package that doesn't set the main: key doesn't get loaded into the global namespace.

So, as discussed above, adding the key

"main": "./lib/index"

in Zappa's package.json file will export the stuff referred to in lib/index.js into the global namespace. This part was mentioned above.

The next obstacle is caused by a similar issue. Coffeescript/optparse is not a valid package key anymore, because the lib: key under directories: doesn't export all the .js files in ./lib as modules anymore. If you go to Zappa's package directory and look at the line that starts with {OptionParser} it should read as follows:

{OptionParser} = require 'coffee-script/lib/optparse'

In other words, when you say required 'coffee-script' that's now an alias to the root of the package's directory structure. So if you want to include other .js files underneath it you have to insert /lib/ inside there.

I don't claim to be any expert, I'm just now starting with node.js and coffeescript and finding them quite useful. I hope this helps some of the people having troubles.

I found enough info to deal with this in this post:

http://groups.google.com/group/npm-/browse_thread/thread/840a0f00fcf82759/02091a167cce17e8

It seems like this actually happened recently and packages haven't dealt with it yet.

CoffeeKup's command-line executable has a similar problem in that it also tries to do

require 'coffee-script/optparse'

So you could edit coffeekup.coffee in CoffeeKup's /bin directory, and change the line that starts with OptionParser to

OptionParser = require('coffee-script/lib/optparse').OptionParser

I don't have Git set up yet to manage these kinds of things, I haven't worked on much collaborative development with Git and I'm hardly qualified to start mucking around with just a week invested into node.js. Perhaps someone with the Git expertise could commit these changes.

kozmikyak commented 13 years ago

There's more. If you have the latest version of Connect and Express, the API changed out from under us. You'll have to find zappa.coffee and change the following at line 88:

  @http_server.use express.static("#{process.cwd()}/public")
  @http_server.use express.bodyParser()
  @http_server.use express.cookieParser()
  @http_server.use express.session({secret: "something"})

In particular, express.static replaces express.staticProvider, express.bodyParser replaces express.bodyDecoder, express.cookieParser replaces express.cookieDecoder, and express.session requires a hash as a parameter with a secret. I'm not yet sure on how to pass in the secret to this--it would have to be set up when the app is set up. I'll have to read up on it.

Syd commented 13 years ago

thanks for that kozmikyak

tobsn commented 13 years ago

yep, still broken. ... and the fixes described here dont make much sense or at least there are no file locations pointed out.

can someone fix this?

volpe commented 13 years ago

Again there is a pull request from nsyee that fixes all the things discussed above issue. I'm not sure what all the extra discussion is about.

Just pull in nsyee's fork.

For those that just want it to work now - use nsyee's fork.

tobsn commented 13 years ago

push it to npm! :P

JiDoc1234 commented 13 years ago

I tried to pull nsyee's fork, says not a valid repository, I get optparse not found