snowcoder
snowcoder

Reputation: 491

Error: Cannot find module 'aws-api-gateway-client'

I am trying to execute nodejs code to invoke AWS API using aws-api-gateway-client module. Code workes perfectly in my laptop however when deployed to TEST server which has latest nodejs and aws npm module installed.

 var apigClientFactory = require('aws-api-gateway-client')

Path Npm modules are installed:

C:\Program Files\nodejs\node_modules\npm\node_modules

Output

''' internal/modules/cjs/loader.js:983
  throw err;
  ^

Error: Cannot find module 'aws-api-gateway-client'
Require stack:
- C:\Myfolder\agent\scripts\NodeJSAWSConnector\APINetworks.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:980:15)
    at Function.Module._load (internal/modules/cjs/loader.js:862:27)
    at Module.require (internal/modules/cjs/loader.js:1042:19)
    at require (internal/modules/cjs/helpers.js:77:18)
    at Object.<anonymous> (C:\ServiceNow\foggydev\agent\scripts\NodeJSAWSConnector\APINetworks.js:8:25)
    at Module._compile (internal/modules/cjs/loader.js:1156:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10)
    at Module.load (internal/modules/cjs/loader.js:1000:32)
    at Function.Module._load (internal/modules/cjs/loader.js:899:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'C:\\MyFolder\\agent\\scripts\\NodeJSAWSConnector\\APINetworks.js'
  ]
}
'''

Please advise on the above issue.

Update 2:

package.json file has entry

 "dependencies": {
        "JSONStream": "^1.3.5",
        "abbrev": "~1.1.1",
        "ansicolors": "~0.3.2",
        "ansistyles": "~0.1.3",
        "aproba": "^2.0.0",
        "archy": "~1.0.0",
        "aws-api-gateway-client": "^0.3.3",
        "aws-sdk": "^2.656.0",
        "bin-links": "^1.1.7",
        "bluebird": "^3.5.5",
        "byte-size": "^5.0.1",
        "cacache": "^12.0.3",
        "call-limit": "^1.1.1",
        "chownr": "^1.1.4",
        "ci-info": "^2.0.0",
        "cli-columns": "^3.1.2",
        "cli-table3": "^0.5.1",

Also, aws-api-gateway-client is installed at C:\Program Files\nodejs\node_modules\npm\node_modules

Upvotes: 0

Views: 1587

Answers (1)

num8er
num8er

Reputation: 19372

Your app is in C:\ServiceNow\foggydev\agent\scripts\NodeJSAWSConnector\APINetworks.js

node_modules are in: C:\Program Files\nodejs\node_modules\npm\node_modules

Seems like You've installed aws-api-gateway-client globally (since You're saying that node_modules folder is in different place)


Steps to check and solve:

1) check package.json file if it exists in dependencies,

2) make sure in Your test server aws-api-gateway-client exists in node_modules folder,

3) do npm i --save aws-api-gateway-client to install it in node_modules folder relative to Your project, which will also add that module to dependencies in package.json

4) deploy to test server again with updated packge.json

Upvotes: 1

Related Questions