5

I have an application successfully working locally so I know the code works. However when I go to deploy to node jitsu I get an error that it cannot find a local module. Here is what I have:

File Setup:

/index.js
/config/config.js

index.js

var cfg = require('./config/config.js');

When trying to deploy node jitsu is giving me an error:

Error: Cannot find module './config/config.js'

Since all this code works locally I do not believe this is a coding issue. I am under the impression that local modules do not need to be included in package.json but perhaps they do for node jitsu? I read their documentation but cannot find anything special for local modules.

Thanks!

nwkeeley
  • 1,397
  • 5
  • 18
  • 28

2 Answers2

11

Local modules like this should work properly.. so long as you don't have it in .gitignore or .npmignore.

Modules in the node_modules directory require that you add it to the bundledDependencies array in your package.json file.

An easy way to check for whether the file is included in your deploy is to run tar -tf $(npm pack).

Sly
  • 1,145
  • 7
  • 19
  • .gitignore had the config.js filename listed in there. Removing that from .gitignore resolved the issue. Thanks! – nwkeeley Dec 03 '12 at 14:51
  • 2
    You could also add an `.npmignore` file if you want to keep it in `.gitignore`, and exclusively allow it. `.npmignore` follows the same format as `.gitignore`, so a simple `!./config/config.js` should work. – Sly Dec 03 '12 at 19:26
3

I had this exact same error on deploy, but caused by a different root cause. In case anybody stumbles into the same problem:

File Setup:

/public/Data/TargetData.js

app.js require statement:

var target = require('./public/data/TargetData.js');

My local Mac OSX environment allowed the capitalization difference of /data/ vs. /Data/ - the Nodejitsu server did not.

KTys
  • 170
  • 1
  • 9