Edge cannot find module 'body-parser' when running server.js

Anyone know why Edge would be complaining that it can't find the body-parser module? This used to work fine, but the message has been coming up in the last week or so. The module's used in a server.js that's called as a target endpoint. Thanks!

Output from the Edge UI:

*** Starting script


*** Error: Cannot find module 'body-parser'
Error: Cannot find module 'body-parser'
    at module.js:340
    at module.js:280
    at module.js:364
    at require (module.js:380)
    at /organization/environment/api/server.js:11
    at module.js:456
    at module.js:474
    at module.js:356
    at module.js:312
    at module.js:497
    at startup (trireme.js:142)
    at trireme.js:923

Lines 11 - 16 of my server.js:

var bodyParser = require('body-parser');


app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
    extended: true
}));

My installed Node modules:

4341-screen-shot-2017-02-13-at-34129-pm.png

The package.json:

{
  "name": "data-manager",
  "version": "0.0.1",
  "description": "Data manager layer for streetcarts.",
  "main": "server.js",
  "dependencies": {
    "async": "^1.5.0",
    "body-parser": "^1.14.1",
    "cors": "^2.5.1",
    "express": "^4.13.3",
    "request": "^2.65.0"
  },
  "devDependencies": {},
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node server.js"
  },
  "license": "ISC"
}
0 5 3,827
5 REPLIES 5

Not applicable

Did you find a solution to this? I am facing the same issue

Hi @Shrawan Raina - Can you share the proxy bundle here ? Has worked for me previously. Would like to try your code and see if I can help

Not applicable

Hi @Sai Saran Vaidyanathan. Thank you for your comment; I got it to work. Had to locally install the body-parser module.

Not applicable

Found out what my trouble was. I ran into this problem because I was deploying my proxies (with a script), then installing the modules. As it turns out, proxies that use the modules (those with the Node.js script) must be deployed *after* the modules are installed. Apparently, they pick up some sort of module registration info when they're deployed.

@Steve Traut Hi, I believe I have the same issue but not clear on what you did to fix it. I am unable to upload a screenshot here, it will not let me but I will explain. Whenever I try the apigeetool to deploy my nodejs app, the node modules never finish uploading. I get the following error: Error: Error uploading resource node_modules\liftoff: 500.

If I leave out the node modules it works, but I need the modules obviously for the app to work. Can you please clarify what you did for yours to work?

Update: My issue is not the same sorry, your issue had to do with when the module is already uploaded, in mine it is not getting that far yet.

Thanks