首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >尝试使用Google Node.js客户端时出现“找不到模块”错误

尝试使用Google Node.js客户端时出现“找不到模块”错误
EN

Stack Overflow用户
提问于 2016-12-30 01:25:55
回答 0查看 1.3K关注 0票数 1

我正尝试在一个新的React Web应用程序上使用Google API Node.js client。这是我的package.json

代码语言:javascript
复制
{
  "name": "onboarding",
  "version": "0.1.0",
  "private": true,
  "devDependencies": {
    "react-scripts": "0.8.4"
  },
  "dependencies": {
    "googleapis": "^15.1.0",
    "react": "^15.4.1",
    "react-dom": "^15.4.1"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  }
}

当我尝试使用以下命令访问App.js中的API时:

代码语言:javascript
复制
var google = require('googleapis');

它不会编译,并给出了:

代码语言:javascript
复制
Failed to compile.

Error in ./~/google-auth-library/lib/auth/googleauth.js
Module not found: 'child_process' in /home/jack/onboarding/node_modules/google-auth-library/lib/auth

 @ ./~/google-auth-library/lib/auth/googleauth.js 21:11-35

Error in ./~/googleapis/lib/generator.js
Module not found: 'swig' in /home/jack/onboarding/node_modules/googleapis/lib

 @ ./~/googleapis/lib/generator.js 21:11-26

Error in ./~/googleapis/lib/generator.js
Module not found: 'js-beautify' in /home/jack/onboarding/node_modules/googleapis/lib

 @ ./~/googleapis/lib/generator.js 22:15-37

我可以通过手动将js-beautifyswig添加到依赖项中来消除它们的错误,但这对child_process不起作用。无论哪种方式,我都觉得我做错了什么。var google = require('googleapis');不应该在react App.js代码中吗?任何建议都将不胜感激。

EN

回答

页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41384440

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档