Developer

Get Involved. Join the Conversation.

Topic

    David Pham
    Connecting NodeJS/Express to Application Container
    Topic posted October 15, 2018 by David PhamGreen Ribbon: 100+ Points, tagged Build, Deployment, Issues 
    155 Views, 2 Comments
    Title:
    Connecting NodeJS/Express to Application Container
    Summary:
    Unable to provision application container with my application files. The command "npm start" does not work
    Content:

    Hi there, I am new to Oracle Application container. I need to upload my application (a website I built using express/nodeJS) to the cloud, but I can't get pass the instance provisioning stage. I use Express application generator (https://expressjs.com/en/starter/generator.html) for my file directory. On localhost, I start my application with "npm start", which runs a file called "www" in the "bin" folder (in the image I attached). This www file is also where I run server-related code, such as server.listen(port). The application works on my local ports, but does not work when I try to deploy it to the application container online.

    I am uploading the entire website.zip file with this as my manifest.json:

    {
      "runtime":{
        "majorVersion":"8"
      },
      "command": "npm start",
      "release": {},
      "notes": "Lets Get Fiscal v1"
    }

     

    My instance won't provision, and the log says: 

    2018-10-15T22:54:14.504809+00:00 ACCS[web.1]: Content of APP_HOME [ /u01/app ] dir
    2018-10-15T22:54:14.517471+00:00 ACCS[web.1]: total 0
    2018-10-15T22:54:14.517567+00:00 ACCS[web.1]: drwxr-xr-x 1 apaas apaas  58 Jan  5  2018 ..
    2018-10-15T22:54:14.517633+00:00 ACCS[web.1]: drwxr-xr-x 1 apaas apaas 270 Oct 15 20:47 website
    2018-10-15T22:54:14.517697+00:00 ACCS[web.1]: drwxrwxr-x 1 apaas apaas  14 Oct 15 22:52 __MACOSX
    2018-10-15T22:54:14.517761+00:00 ACCS[web.1]: drwxr-xr-x 1 apaas apaas  30 Oct 15 22:54 .
    2018-10-15T22:54:14.518758+00:00 ACCS[web.1]: Application should listen on 0.0.0.0:$PORT [enabling app to listen on all interfaces on $PORT env variable]
    2018-10-15T22:54:14.520270+00:00 ACCS[web.1]: Starting application with launch command [ node ./bin/www ]
    2018-10-15T22:54:14.642458+00:00 APP[web.1]: module.js:538
    2018-10-15T22:54:14.642662+00:00 APP[web.1]:     throw err;
    2018-10-15T22:54:14.642820+00:00 APP[web.1]:     ^
    2018-10-15T22:54:14.642974+00:00 APP[web.1]: 
    2018-10-15T22:54:14.643170+00:00 APP[web.1]: Error: Cannot find module '/u01/app/bin/www'
    2018-10-15T22:54:14.643324+00:00 APP[web.1]:     at Function.Module._resolveFilename (module.js:536:15)
    2018-10-15T22:54:14.643481+00:00 APP[web.1]:     at Function.Module._load (module.js:466:25)
    2018-10-15T22:54:14.643640+00:00 APP[web.1]:     at Function.Module.runMain (module.js:676:10)
    2018-10-15T22:54:14.643795+00:00 APP[web.1]:     at startup (bootstrap_node.js:187:16)
    2018-10-15T22:54:14.643974+00:00 APP[web.1]:     at bootstrap_node.js:608:3

    Why can't the module /u01/app/bin/www be found and what can I do to fix it?

     

    Image:

    Comment

     

    • Peter Nagy

      Hi David,

      I suspect when you installed Express you did it globally:

      $npm install express-generator -g

      however you need to install Express locally into the context of your application. Otherwise it will not be available in the node_modules folder where application will search the dependencies. Use

      $ npm install express

      without -g option.

      Hope this helps.

      Peter

       

    • David Pham

      Hi there, the problem was not the installation but I needed to zip the file contents instead of the actual file. Thank you :)