找不到angular2 google-auth-library模块:错误:无法解决' child_process'

时间:2016-10-28 08:57:54

标签: angular google-api google-api-nodejs-client

我试图在新的angular2项目中使用google api。 正如文档所示,我在使用angular-cli创建的新项目中安装了googleapis(npm install googleapis --save)。

当我开始时,我有以下错误:

ERROR in ./~/google-auth-library/lib/auth/googleauth.js
Module not found: Error: Can't resolve 'child_process' in '/home/adrien/perso/ng2-google-calendar-api/node_modules/google-auth-library/lib/auth'
 @ ./~/google-auth-library/lib/auth/googleauth.js 21:11-35
 @ ./~/googleapis/lib/googleapis.js
 @ ./src/app/app.component.ts
 @ ./src/app/index.ts
 @ ./src/main.ts
 @ multi main

ERROR in ./~/forever-agent/index.js
Module not found: Error: Can't resolve 'net' in '/home/adrien/perso/ng2-google-calendar-api/node_modules/forever-agent'
 @ ./~/forever-agent/index.js 6:10-24
 @ ./~/google-auth-library/~/request/request.js
 @ ./~/google-auth-library/~/request/index.js
 @ ./~/google-auth-library/lib/transporters.js
 @ ./~/google-auth-library/lib/auth/googleauth.js
 @ ./~/googleapis/lib/googleapis.js
 @ ./src/app/app.component.ts
 @ ./src/app/index.ts
 @ ./src/main.ts
 @ multi main

ERROR in ./~/forever-agent/index.js
Module not found: Error: Can't resolve 'tls' in '/home/adrien/perso/ng2-google-calendar-api/node_modules/forever-agent'
 @ ./~/forever-agent/index.js 7:10-24
 @ ./~/google-auth-library/~/request/request.js
 @ ./~/google-auth-library/~/request/index.js
 @ ./~/google-auth-library/lib/transporters.js
 @ ./~/google-auth-library/lib/auth/googleauth.js
 @ ./~/googleapis/lib/googleapis.js
 @ ./src/app/app.component.ts
 @ ./src/app/index.ts
 @ ./src/main.ts
 @ multi main

ERROR in ./~/tough-cookie/lib/cookie.js
Module not found: Error: Can't resolve 'net' in '/home/adrien/perso/ng2-google-calendar-api/node_modules/tough-cookie/lib'
 @ ./~/tough-cookie/lib/cookie.js 32:10-24
 @ ./~/google-auth-library/~/request/lib/cookies.js
 @ ./~/google-auth-library/~/request/index.js
 @ ./~/google-auth-library/lib/transporters.js
 @ ./~/google-auth-library/lib/auth/googleauth.js
 @ ./~/googleapis/lib/googleapis.js
 @ ./src/app/app.component.ts
 @ ./src/app/index.ts
 @ ./src/main.ts
 @ multi main

ERROR in ./~/tunnel-agent/index.js
Module not found: Error: Can't resolve 'net' in '/home/adrien/perso/ng2-google-calendar-api/node_modules/tunnel-agent'
 @ ./~/tunnel-agent/index.js 3:10-24
 @ ./~/google-auth-library/~/request/lib/tunnel.js
 @ ./~/google-auth-library/~/request/request.js
 @ ./~/google-auth-library/~/request/index.js
 @ ./~/google-auth-library/lib/transporters.js
 @ ./~/google-auth-library/lib/auth/googleauth.js
 @ ./~/googleapis/lib/googleapis.js
 @ ./src/app/app.component.ts
 @ ./src/app/index.ts
 @ ./src/main.ts
 @ multi main

ERROR in ./~/tunnel-agent/index.js
Module not found: Error: Can't resolve 'tls' in '/home/adrien/perso/ng2-google-calendar-api/node_modules/tunnel-agent'
 @ ./~/tunnel-agent/index.js 4:10-24
 @ ./~/google-auth-library/~/request/lib/tunnel.js
 @ ./~/google-auth-library/~/request/request.js
 @ ./~/google-auth-library/~/request/index.js
 @ ./~/google-auth-library/lib/transporters.js
 @ ./~/google-auth-library/lib/auth/googleauth.js
 @ ./~/googleapis/lib/googleapis.js
 @ ./src/app/app.component.ts
 @ ./src/app/index.ts
 @ ./src/main.ts
 @ multi main

这是我的package.json:

{
  "name": "ng2-google-calendar-api",
  "version": "0.0.0",
  "license": "MIT",
  "angular-cli": {},
  "scripts": {
    "start": "ng serve",
    "lint": "tslint \"src/**/*.ts\"",
    "test": "ng test",
    "pree2e": "webdriver-manager update",
    "e2e": "protractor"
  },
  "private": true,
  "dependencies": {
    "@angular/common": "~2.0.0",
    "@angular/compiler": "~2.0.0",
    "@angular/core": "~2.0.0",
    "@angular/forms": "~2.0.0",
    "@angular/http": "~2.0.0",
    "@angular/platform-browser": "~2.0.0",
    "@angular/platform-browser-dynamic": "~2.0.0",
    "@angular/router": "~3.0.0",
    "core-js": "^2.4.1",
    "googleapis": "^14.1.0",
    "rxjs": "5.0.0-beta.12",
    "systemjs": "^0.19.40",
    "ts-helpers": "^1.1.1",
    "zone.js": "^0.6.23"
  },
  "devDependencies": {
    "@types/jasmine": "^2.2.30",
    "@types/node": "^6.0.42",
    "angular-cli": "1.0.0-beta.17",
    "codelyzer": "~0.0.26",
    "jasmine-core": "2.4.1",
    "jasmine-spec-reporter": "2.5.0",
    "karma": "1.2.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-cli": "^1.0.1",
    "karma-jasmine": "^1.0.2",
    "karma-remap-istanbul": "^0.2.1",
    "protractor": "4.0.9",
    "ts-node": "1.2.1",
    "tslint": "3.13.0",
    "typescript": "2.0.2"
  }
}

我的节点版本是6.9.0 我的npm版本是3.10.8 我的angular-cli版本是1.0.0-beta.18

提前感谢您的反馈或主意

0 个答案:

没有答案