zaid007
zaid007

Reputation: 1

I am doing razorpay integration in Node Js. But when i start my Node Js server with "npm start" it shows the following error in console. Help me out?

enter image description hereee

E:\myHp\RazorPayIntegration\server>npm start

[email protected] start E:\myHp\RazorPayIntegration\server node app.js

E:\myHp\RazorPayIntegration\server\node_modules\razorpay\dist\razorpay.js:33 throw new Error('key_id is mandatory'); ^

Error: key_id is mandatory at new Razorpay (E:\myHp\RazorPayIntegration\server\node_modules\razorpay\dist\razorpay.js:33:13) at Object. (E:\myHp\RazorPayIntegration\server\routes\razorpayRouter.js:9:23) at Module._compile (internal/modules/cjs/loader.js:1068:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10) at Module.load (internal/modules/cjs/loader.js:933:32) at Function.Module._load (internal/modules/cjs/loader.js:774:14) at Module.require (internal/modules/cjs/loader.js:957:19) at require (internal/modules/cjs/helpers.js:88:18) at Object. (E:\myHp\RazorPayIntegration\server\app.js:11:22) at Module._compile (internal/modules/cjs/loader.js:1068:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10) at Module.load (internal/modules/cjs/loader.js:933:32) at Function.Module._load (internal/modules/cjs/loader.js:774:14) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12) at internal/main/run_main_module.js:17:47 npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! [email protected] start: node app.js npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the [email protected] start script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\Zaid\AppData\Roaming\npm-cache_logs\2021-06-10T19_21_09_479Z-debug.log

Upvotes: -1

Views: 475

Answers (1)

Souvik Mern Stacker
Souvik Mern Stacker

Reputation: 1

make sure that you imported "dotenv" module. First see if your Razorpay Key Id was assigned by the value which you declared into .env file or not. Simply do console.log(Key_id); I guess it will return "undefined", if so then import "dotenv" module.

const path = require("path");

require("dotenv").config({ path: path.resolve(__dirname, "../src/.env") });

In my case the ".env" file exist inside the src/ I hope this will resolve your error.

Upvotes: 0

Related Questions