Question

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!

Was it helpful?

Solution

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).

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top