Can't find module googleapis

自古美人都是妖i 提交于 2019-12-10 12:55:43

问题


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.


回答1:


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


来源:https://stackoverflow.com/questions/44818791/cant-find-module-googleapis

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!