Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't find module googleapis

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

  1. npm install googleapis --save
  2. npm install googleapis
  3. npm install (add module to package.json file)

but these methods didn't work.

I found the googleapis module in the node_modules directory.

like image 398
Harsh Patel Avatar asked Jun 29 '17 07:06

Harsh Patel


1 Answers

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:

  1. npm i typescript -g
  2. npm run build
like image 94
Max Avatar answered Dec 11 '22 10:12

Max