Search code examples
node.jsnodejitsu

Cannot find module on start of new Nodejitsu deployment


I have a node application that runs locally and when deploying to Nodejitsu via jitsu deploy, the CLI reports a successful deployment. However, when actually logging in to look at the application via the web based interface and attempting to activate the snapshot, the start fails with the following error:-

err Wed, 05 Nov 2014 14:10:37 GMT 
err Wed, 05 Nov 2014 14:10:37 GMT module.js:340
err Wed, 05 Nov 2014 14:10:37 GMT throw err;
err Wed, 05 Nov 2014 14:10:37 GMT Error: Cannot find module '/opt/run/snapshot/package/js'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3
err Wed, 05 Nov 2014 14:10:37 GMT ^

The trouble I am having, is the vagueness of the error. What is '/opt/run/snapshot/package/js'? Is there a way of getting more detail out of Nodejitsu so I can see what maybe causing the problem? Is this something anyone else has had?

I can return to this question with more information if requested.

Help, as always, appreciated.


Solution

  • I solved this. The problem was in my packages.json I had the following:-

       "scripts": {
            "start": "js server",
            "postinstall": "bower install",
            "test": "make test-cov"
        },
    

    js is of course not recognised by Nodejitsu on run. I found, by changing it to:-

    "scripts": {
        "start": "node server.js"
    },
    

    I had no problems.

    A note to future Nodejitsu deployers, postinstall runs locally -- not on the server; therefore remove bower_components from your .gitignore if you need bower components on nodejitsu.

    Hope this helps any adventurers who wander by.