Cannot find googleapis module

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 mistake:

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 reinstalling the modules using these methods

  • npm install googleapis --save
  • npm install googleapis
  • npm install (add module to package.json file)

but these methods did not work.

I found googleapis module in node_modules directory.

+4
source share
1 answer

I tried it myself, got the same problem. Looking at node_modules / googleapis / package.json, I found out that the file node_modules / googleapis / lib / googleapis.js is missing. Reinstalling googleapis did not help.

The solution for me was to create googleapis. To do this, go to the directory ./node_modules/googleapisand run two commands:

  • npm i typescript -g
  • npm run build
+7
source

Source: https://habr.com/ru/post/1680388/


All Articles