Unable to import module 'index': Error in aws cloud watch logs while using firebase-admin module - amazon-web-services

I am trying to retrieve data from a firebase database when an alexa intent is triggered. Whereas everything is set up, the lambda function crashes as soon as I am requiring the firebase-admin module.
I am using the recommended way of authentication:
const admin = require('firebase-admin');
const serviceAccount = require("./{{GENERATED_JSON_FROM_FIREBASE}}.json");
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: "https://{{MY_FIREBASE}}.firebaseio.com"
});
Here's the error from CloudWatch:
Unable to import module 'index': Error
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/var/task/node_modules/firebase-admin/node_modules/grpc/src/node/src/grpc_extension.js:30:15)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
END RequestId: 13504ee8-ac0a-11e7-bef6-2bc764d73bbe
Line 30 in grpc_extension.js says:
var binding = require(binding_path);
Any help for a total newbie?
EDIT:
As other solutions to similiar problems state, that false zipping may cause the error, I want to make clear, that I zip only the contents of my project folder by using the terminal
command zip -r myskill.zip *
Moreover I executed chmod -R 777 on the node_modules/ folder

Related

error when launching postman client in linux

i downloaded the latest postman client for RHEL7.
when trying to launch the client i am seeing the following error.
any pointers greatly appreciated.
A JavaScript error occurred in the main process
Uncaught Exception:
Error: Failed to get 'userData' path
at Object.<anonymous> (/home/xxxxxxx/spec/Postman/app/resources/app/common/controllers/WindowController.js:4:27)
at Module._compile (node:internal/modules/cjs/loader:1110:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1140:10)
at Module.load (node:internal/modules/cjs/loader:982:32)
at Module._load (node:internal/modules/cjs/loader:823:12)
at Function.c._load (node:electron/js2c/asar_bundle:5:13331)
at Module.require (node:internal/modules/cjs/loader:1006:19)
at require (node:internal/modules/cjs/helpers:93:18)
at Object.<anonymous> (/home/xxxxxxx/spec/Postman/app/resources/app/services/windowManager.js:14:22)
at Module._compile (node:internal/modules/cjs/loader:1110:14)

Cant seem to run aws cdk command?

I just re-installed aws cdk and when i run cdk synth I am getting this error:
/usr/local/lib/node_modules/aws-cdk/lib/index.js:4920
} catch {
^
SyntaxError: Unexpected token {
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:616:28)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/usr/local/lib/node_modules/aws-cdk/bin/cdk.js:3:15)
I was able to solve this by changing my node version to 16.16.0

Kubernetes param store issue

I get an error related to aws paramstore in kubernetes container.
[1/4] Resolving packages...
success Already up-to-date.
Done in 1.00s.
yarn run v1.22.5
$ db-migrate --config ./src/db/config.js --migrations-dir ./src/db/migrations -e config up
[ERROR] Error: getaddrinfo EAI_AGAIN ssm.eu-west-1.amazonaws.com
at ParameterQuery.executeSync (/backend/node_modules/aws-param-store/lib/param_query.js:99:19)
at getParametersSync (/backend/node_modules/aws-param-store/lib/index.js:49:10)
at /backend/config/__helpers/awsParams.js:23:34
at Array.reduce (<anonymous>)
at retrieveAWSParams (/backend/config/__helpers/awsParams.js:22:28)
at getAwsParams (/backend/config/__helpers/awsParams.js:61:22)
at Object.<anonymous> (/backend/config/index.js:21:13)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.

nodemon runs different version of simply node

I will try to summarize my problem here.
I have one nodeJS application, that application need to run in node version >14 our <12.
When I try to run using node command, it works fine, they use node version 14. But when I try to run with nodemon, the app crashes. I start to using node --version alert and see the nodemon use version 13.
plemos#ubuntu:~/Documents/company-BE$ node index.js
redis.port: 6379
redis.host: localhost
Initiating queue ...
process.env.NODE_ENV: local
process.env.GOOGLE_APPLICATION_CREDENTIALS: /home/plemos/Documents/company-BE/googleKey.json
database: localhost:27017
databaseOption: {"poolSize":5,"useNewUrlParser":true,"useFindAndModify":false,"useCreateIndex":true,"useUnifiedTopology":true,"authSource":"admin","dbName":"company"}
(node:28861) Warning: Accessing non-existent property 'count' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
(node:28861) Warning: Accessing non-existent property 'findOne' of module exports inside circular dependency
(node:28861) Warning: Accessing non-existent property 'remove' of module exports inside circular dependency
(node:28861) Warning: Accessing non-existent property 'updateOne' of module exports inside circular dependency
company BackEnd server start DEV on port 6008!
Versions: {"node":"14.16.0","v8":"8.4.371.19-node.18","uv":"1.40.0","zlib":"1.2.11","brotli":"1.0.9","ares":"1.16.1","modules":"83","nghttp2":"1.41.0","napi":"7","llhttp":"2.1.3","openssl":"1.1.1j","cldr":"37.0","icu":"67.1","tz":"2020a","unicode":"13.0"}
mongodb connection string: localhost:27017/company
connected to mongodb
Run nodemon
nodemon
[nodemon] 2.0.7
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js
[nodemon] starting `node --version; node index.js`
v13.6.0
/home/plemos/Documents/company-BE/node_modules/uuid/dist/esm-browser/index.js:1
export { default as v1 } from './v1.js';
^^^^^^
SyntaxError: Unexpected token 'export'
at wrapSafe (internal/modules/cjs/loader.js:1060:16)
at Module._compile (internal/modules/cjs/loader.js:1108:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1164:10)
at Module.load (internal/modules/cjs/loader.js:993:32)
at Function.Module._load (internal/modules/cjs/loader.js:892:14)
at Module.require (internal/modules/cjs/loader.js:1033:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (/home/plemos/Documents/company-BE/src/controllers/bulkImport/doBulkImport.js:26:24)
at Module._compile (internal/modules/cjs/loader.js:1144:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1164:10)
at Module.load (internal/modules/cjs/loader.js:993:32)
at Function.Module._load (internal/modules/cjs/loader.js:892:14)
at Module.require (internal/modules/cjs/loader.js:1033:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (/home/plemos/Documents/company-BE/src/routes/bulkImport.js:80:17)
at Module._compile (internal/modules/cjs/loader.js:1144:30)
Any sugestions ?

module initialization error TypeError in AWS Lambda with AWS SDK nodejs

I am writing some lambda's and In those lambda's I am using aws sdk to use some of the services, It's working fine for some service and it's not working for some services, in some services it say's module initialization error. What is wrong here, why some aws sdk modules only throw this error?
the error log from watch log:
START RequestId: dcbf2a88-d723-4a4e-8be9-896887150169 Version: $LATEST
module initialization error: TypeError
at Object.<anonymous> (/var/task/src/functions/routes/handler.js:4:18)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
END RequestId: dcbf2a88-d723-4a4e-8be9-896887150169
REPORT RequestId: dcbf2a88-d723-4a4e-8be9-896887150169 Duration: 38.90 ms Billed Duration: 100 ms Memory Size: 1024 MB Max Memory Used: 69 MB
line number 4 in the error is object creation code
const text = new AWS.Textract({apiVersion: '2018-06-27'});