node jitsu cannot find local modules
Asked Answered
T

2

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!

Taillight answered 2/12, 2012 at 16:46 Comment(0)
E
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).

Edita answered 2/12, 2012 at 19:4 Comment(2)
.gitignore had the config.js filename listed in there. Removing that from .gitignore resolved the issue. Thanks!Taillight
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.Edita
I
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.

Islamite answered 17/3, 2014 at 19:18 Comment(1)
Man thanks for posting this, saved me a bunch of time.Cookie

© 2022 - 2024 — McMap. All rights reserved.