This is my code:
var http = require('http');
var express = require('express');
var Session = require('express-session');
var google = require('googleapis');
var plus = google.plus('v1');
var OAuth2 = google.auth.OAuth2;
This is an error:
Error: Cannot find module 'googleapis'
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> (/home/software/Harsh Patel/test/demo_auth/server.js:4:14)
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)
I tried to reinstall modules with these methods
npm install googleapis --save
npm install googleapis
npm install
(add module to package.json file)but these methods didn't work.
I found the googleapis module in the node_modules
directory.
I tried it myself, got the same problem. After looking at node_modules/googleapis/package.json I found out, that node_modules/googleapis/lib/googleapis.js file is missing. Reinstalling googleapis wasn't helping.
Solution for me was to build googleapis. To do that, navigate to ./node_modules/googleapis
directory and execute 2 commands:
npm i typescript -g
npm run build
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With