Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 使用带有Web包的google api nodejs客户端生成grunt时出错_Node.js_Reactjs_Webpack_Google Api Nodejs Client_Google Api Js Client - Fatal编程技术网

Node.js 使用带有Web包的google api nodejs客户端生成grunt时出错

Node.js 使用带有Web包的google api nodejs客户端生成grunt时出错,node.js,reactjs,webpack,google-api-nodejs-client,google-api-js-client,Node.js,Reactjs,Webpack,Google Api Nodejs Client,Google Api Js Client,我在ReactJS网页包应用程序中使用。它确实有一个警告,它是alpha版本,所以问题是意料之中的,这就是我遇到的问题 npm安装googleapis——保存installedgoogleapisok, 在我的package.json中添加了“googleapis”:“^2.0.2”,但当我运行grunt build时,我会收到以下警告(后面是大量错误,我会根据请求发布,因为这是大量文本): ~/googleapis/api/index.js中有问题的行是: var Endpoint = req

我在ReactJS网页包应用程序中使用。它确实有一个警告,它是alpha版本,所以问题是意料之中的,这就是我遇到的问题

npm安装googleapis——保存
installed
googleapis
ok, 在我的package.json中添加了
“googleapis”:“^2.0.2”
,但当我运行
grunt build
时,我会收到以下警告(后面是大量错误,我会根据请求发布,因为这是大量文本):

~/googleapis/api/index.js
中有问题的行是:

var Endpoint = require(endpointPath);
我遇到的一个错误是:

ERROR in ./~/googleapis/~/request/~/hawk/~/hoek/lib/index.js
Module not found: Error: Cannot resolve module 'fs' in /Users/dev/wwb-web-app/node_modules/googleapis/node_modules/request/node_modules/hawk/node_modules/hoek/lib
 @ ./~/googleapis/~/request/~/hawk/~/hoek/lib/index.js 3:9-22
在我的React组件中需要googleapis的代码:

var gapi = require('googleapis');
注意:组件中的任何其他代码都可以根据要求提供,但我认为它与此问题无关

我的
package.json
依赖项:

"dependencies": {
"aws-sdk": "^2.0.21",
"chalk": "^0.5.0",
"crypto-js": "^3.1.2-5",
"cryptojs": "^2.5.3",
"envify": "^1.2.1",
"fluxxor": "1.5.1",
"googleapis": "^2.0.2",
"imports-loader": "^0.6.3",
"jquery": "~2.1.1",
"moment": "^2.8.3",
"react": "0.11.1",
"react-bootstrap": "0.12.0",
"react-router": "0.5.2",
"react-router-bootstrap": "0.5.0"
},
"devDependencies": {
"connect-livereload": "^0.4.0",
"css-loader": "^0.7.0",
"es6-promise": "^1.0.0",
"esrever": "^0.1.0",
"grunt": "^0.4.5",
"grunt-contrib-copy": "^0.5.0",
"grunt-contrib-less": "~0.11.4",
"grunt-contrib-uglify": "^0.7.0",
"grunt-contrib-watch": "^0.6.1",
"grunt-git": "^0.2.14",
"grunt-gitinfo": "^0.1.6",
"grunt-karma": "^0.8.3",
"grunt-lesslint": "^1.1.13",
"grunt-rsync": "^0.6.1",
"grunt-ssh": "^0.11.2",
"grunt-webpack": "^1.0.8",
"jssha": "^1.5.0",
"jsx-loader": "^0.10.2",
"karma": "^0.12.17",
"karma-chrome-launcher": "^0.1.7",
"karma-coverage": "^0.2.7",
"karma-jasmine": "^0.1.5",
"karma-js-coverage": "^0.4.0",
"karma-osx-reporter": "^0.1.0",
"karma-phantomjs-launcher": "^0.1.4",
"karma-sourcemap-loader": "^0.3.2",
"karma-webpack": "^1.2.1",
"load-grunt-tasks": "^0.6.0",
"style-loader": "^0.6.4",
"time-grunt": "^1.0.0",
"webpack": "^1.4.15"
}
npm版本2.5.1

节点版本v0.12.1


提前感谢您的帮助

我没有有效的答案,但我也在寻找答案。您是GitHub上的dmk12吗?如果没有,请查看此问题:

看起来问题的一部分是图书馆有一条线

var Endpoint=require(endpointPath)

必须对其进行评估,因为
endpointPath
是一个变量。不幸的是,这个问题说他们可能不会改变这种行为,因为这使他们的代码更加灵活。一个人(也许你?)建议通过
index.html
中的
标签加载API来解决这个问题,但这对我们不起作用——我的团队和我想从服务器端代码使用API

搜索答案的过程仍在继续。

正如浏览器使用情况所阐明的,google api nodejs客户端项目不支持该选项。它仅供服务器端使用

为了解决如何在React网页包应用程序中使用Google API这一更广泛的问题,基于Redux的Gmail客户端提供了一个示例

在NuclearMail的入口点,加载Webpack包,然后使用
handleGoogleClientLoad
回调加载Google API:



是的,我是Github上的dmk12,回复了您的评论。搜寻还在继续。有人找到答案吗?我也有同样的问题。
"dependencies": {
"aws-sdk": "^2.0.21",
"chalk": "^0.5.0",
"crypto-js": "^3.1.2-5",
"cryptojs": "^2.5.3",
"envify": "^1.2.1",
"fluxxor": "1.5.1",
"googleapis": "^2.0.2",
"imports-loader": "^0.6.3",
"jquery": "~2.1.1",
"moment": "^2.8.3",
"react": "0.11.1",
"react-bootstrap": "0.12.0",
"react-router": "0.5.2",
"react-router-bootstrap": "0.5.0"
},
"devDependencies": {
"connect-livereload": "^0.4.0",
"css-loader": "^0.7.0",
"es6-promise": "^1.0.0",
"esrever": "^0.1.0",
"grunt": "^0.4.5",
"grunt-contrib-copy": "^0.5.0",
"grunt-contrib-less": "~0.11.4",
"grunt-contrib-uglify": "^0.7.0",
"grunt-contrib-watch": "^0.6.1",
"grunt-git": "^0.2.14",
"grunt-gitinfo": "^0.1.6",
"grunt-karma": "^0.8.3",
"grunt-lesslint": "^1.1.13",
"grunt-rsync": "^0.6.1",
"grunt-ssh": "^0.11.2",
"grunt-webpack": "^1.0.8",
"jssha": "^1.5.0",
"jsx-loader": "^0.10.2",
"karma": "^0.12.17",
"karma-chrome-launcher": "^0.1.7",
"karma-coverage": "^0.2.7",
"karma-jasmine": "^0.1.5",
"karma-js-coverage": "^0.4.0",
"karma-osx-reporter": "^0.1.0",
"karma-phantomjs-launcher": "^0.1.4",
"karma-sourcemap-loader": "^0.3.2",
"karma-webpack": "^1.2.1",
"load-grunt-tasks": "^0.6.0",
"style-loader": "^0.6.4",
"time-grunt": "^1.0.0",
"webpack": "^1.4.15"
}