Error: Cannot find module 'aws-api-gateway-client' - node.js

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

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

Related

When I try to run parcel, which is a node.js module, I get ERR_DLOPEN_FAILED error

EDIT: My problem is solved. Link for solution
First of all, hello everyone,
Although dependencies and dev dependencies are specified in the package.json file (I also downloaded the modules to the node_modules folder with the npm install command), I get the following error when I enter the npx parcel index.html command. What would be the reason?
"devDependencies": {
"#parcel/transformer-sass": "^2.6.0",
"parcel": "^2.6.0"
},
"dependencies": {
"bootstrap-icons": "^1.8.3"
}
Console output:
PS C:\Users\ubeyd\GitHub\countrypedia> npx parcel index.html
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
Error: The specified module could not be found.
\\?\C:\Users\ubeyd\GitHub\countrypedia\node_modules\#parcel\source-map\parcel_sourcemap_node\artifacts\index.win32-x64-msvc.node
at Object.Module._extensions..node (node:internal/modules/cjs/loader:1189:18)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (C:\Users\ubeyd\GitHub\countrypedia\node_modules\v8-compile-cache\v8-compile-cache.js:159:20)
at Object.<anonymous> (C:\Users\ubeyd\GitHub\countrypedia\node_modules\#parcel\source-map\parcel_sourcemap_node\index.js:15:18)
at Module._compile (C:\Users\ubeyd\GitHub\countrypedia\node_modules\v8-compile-cache\v8-compile-cache.js:192:30)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12) {
code: 'ERR_DLOPEN_FAILED'
}

When i execute $firebase deploy command i get this error?

I want to create an http function to upload image to firebase storage using firebase cloud functions.
package.json
"dependencies": {
"#google-cloud/storage": "^2.3.0",
"busboy": "^0.2.14",
"cors": "^2.8.5",
"firebase-admin": "^6.1.0",
"firebase-functions": "^2.1.0",
"uuid": "^3.3.2"
}
Error
Error: Error occurred while parsing your function triggers.
TypeError: require(...) is not a function
at Object.<anonymous> (/home/a7me63azza8/Desktop/flutter/flutter_course/functions/index.js:21:45)
at Module._compile (internal/modules/cjs/loader.js:688:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10) at Module.load (internal/modules/cjs/loader.js:598:32)
at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
at Function.Module._load (internal/modules/cjs/loader.js:529:3)
at Module.require (internal/modules/cjs/loader.js:636:17)
at require (internal/modules/cjs/helpers.js:20:18)
at /usr/lib/node_modules/firebase-tools/lib/triggerParser.js:15:15
at Object.<anonymous> (/usr/lib/node_modules/firebase-
tools/lib/triggerParser.js:53:3)
Error screen shot
I am doing the udemy flutter course as well, and there was a document that asked you to install version 1.7 of #google-cloud/storage.
This worked for me, run:
npm install --save #google-cloud/storage#1.7
then run: firebase deploy

node keystone Cannot find module './browserify'

Everything was working until I did a npm install on my project folder.
I am running macOS Sierra 10.12.5, node.js v8.2.1, npm v5.3.0
What I have tried:
uninstalling node/npm and reinstalling
npm install -g browserify
npm insatll browserify on my project folder
reinstall KeystoneJS generator
my package.json
{
"name": "site-name",
"version": "0.0.0",
"private": true,
"dependencies": {
"keystone": "4.0.0-beta.5",
"lodash": "^4.13.1",
"consolidate": "0.14.5",
"nunjucks": "3.0.0",
"node-sass": "4.5.0",
"node-sass-middleware": "0.11.0",
"dotenv": "4.0.0",
"async": "2.1.4",
"express-sslify": "1.2.0"
},
"devDependencies": {
"eslint": "3.15.0",
"eslint-config-keystone": "3.0.0",
"eslint-plugin-react": "^5.1.1"
},
"scripts": {
"lint": "eslint .",
"start": "node keystone.js"
}
}
Here is the output in terminal
node keystone
module.js:487
throw err;
^
Error: Cannot find module './browserify'
at Function.Module._resolveFilename (module.js:485:15)
at Function.Module._load (module.js:437:25)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/Tyler/Desktop/Forge_Fitness_Site/models/node_modules/sha.js/bin.js:3:18)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
at /Users/Tyler/Desktop/Forge_Fitness_Site/node_modules/keystone/lib/core/importer.js:42:23
at Array.forEach (native)
at importer (/Users/Tyler/Desktop/Forge_Fitness_Site/node_modules/keystone/lib/core/importer.js:32:26)
at /Users/Tyler/Desktop/Forge_Fitness_Site/node_modules/keystone/lib/core/importer.js:36:22
at Array.forEach (native)
at importer (/Users/Tyler/Desktop/Forge_Fitness_Site/node_modules/keystone/lib/core/importer.js:32:26)
at /Users/Tyler/Desktop/Forge_Fitness_Site/node_modules/keystone/lib/core/importer.js:36:22
at Array.forEach (native)
at importer (/Users/Tyler/Desktop/Forge_Fitness_Site/node_modules/keystone/lib/core/importer.js:32:26)
at Keystone.import (/Users/Tyler/Desktop/Forge_Fitness_Site/node_modules/keystone/index.js:176:42)
at Object.<anonymous> (/Users/Tyler/Desktop/Forge_Fitness_Site/keystone.js:41:16)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
Well, I fixed the issue, not exactly sure how it happened but somehow I ended up with two node_modules folders in my project directory. Deleting the second one fixed my issue.

Heroku Cannot find module 'lodash/object/assign'

I'm having issues deploying to Heroku. Got it running locally after i had the same error by simply rm -f node_modules and then reinstalling them with npm install. But when i deploy to heroku the error keeps occurring. Even went in with bash to perform the same steps.
I then used npm shrinkwrap and noticed aws-sdk has a dependency on lodash vs 3.5.0 <3.6.0. So i set the lodash version in my package.json accordingly.
It all still runs locally but keeps crashing on heroku.
Node v5.0.0
NPM v3.3.6
"dependencies": {
"aws-sdk": "^2.6.6",
"bluebird": "^3.4.6",
"body-parser": "^1.15.2",
"express": "^4.14.0",
"goosepage": "0.0.1",
"lodash": "^3.5.0"
}
Additional heroku log
Error: Cannot find module 'lodash/object/assign'
Function.Module._resolveFilename (module.js:337:15)
Function.Module._load (module.js:287:25)
Module.require (module.js:366:17)
require (module.js:385:17)
Object.<anonymous> (/app/node_modules/xmlbuilder/lib/index.js:5:12)
Object.<anonymous> (/app/node_modules/xmlbuilder/lib/index.js:14:4)
Module._compile (module.js:425:26)
Object.Module._extensions..js (module.js:432:10)
Module.load (module.js:356:32)
Function.Module._load (module.js:311:12)
Module.require (module.js:366:17)
require (module.js:385:17)
Object.<anonymous> (/app/node_modules/aws-sdk/lib/xml/builder.js:2:15)
Module._compile (module.js:425:26)
Object.Module._extensions..js (module.js:432:10)
Module.load (module.js:356:32)
Turns out Heroku had a Buildpack that was caching node_modules. Turning off caching didnt help so i had to use the heroku plugin to clear the cached which worked.
https://github.com/heroku/heroku-repo
heroku repo:purge_cache -a appname
The following allegedly should also work incase the above doesn't
heroku config:set NODE_MODULES_TRUE=false

Debugging module throw errors?

I just started messing with node.js and I'm already having problems, I have no idea how to even start debugging this..
> npm install express jade socket.io
module.js:333
throw err;
^
Error: Cannot find module 'cookie-jar'
at Function.Module._resolveFilename (module.js:331:15)
at Function.Module._load (module.js:273:25)
at Module.require (module.js:357:17)
at require (module.js:373:17)
at Object.<anonymous> (/usr/local/Cellar/node/0.10.24/lib/node_modules/npm/node_modules/request/index.js:15:14)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:349:32)
at Function.Module._load (module.js:305:12)
at Module.require (module.js:357:17)
If you want to just use npm just install each package with a separate command
npm install express
npm install jade
npm install socket.io
On my computer it works.
My suggestion is to use the "package.json" file. In that file you can specify the libraries you need and it's going to download the dependencies for you.
For example
{
"name": "myapp",
"version": "0.0.1",
"author": "Alvise Susmel <alvise#50pixels.com>",
"dependencies": {
"jade": "*",
"express": "*",
"socket.io": "*"
}
}
and just execute
npm install
And npm will make all for you. It will create a "node_modules" where there are the dependencies.
Just create your js files in the same directory of "node_modules" and the dependencies will be all available to be included.
As you can see in the package.json file, near every dependency, there is a " * ", that means "all versions". If you want, you can set a specific version.
If you want to know more about this, that's a useful link: https://npmjs.org/doc/json.html

Resources