googleapis / google-api-nodejs-client

Google's officially supported Node.js client library for accessing Google APIs. Support for authorization and authentication with OAuth 2.0, API Keys and JWT (Service Tokens) is included.
https://googleapis.dev/nodejs/googleapis/latest/
Apache License 2.0
11.36k stars 1.92k forks source link

Problem with Angular-cli #678

Closed diiiiiego83 closed 7 years ago

diiiiiego83 commented 7 years ago

Hi, I'm having this problem when i try to import the googleapis package (i'm writing a project with angular-cli):

ERROR in ./~/google-auth-library/lib/auth/googleauth.js
Module not found: Error: Can't resolve 'child_process' in 'C:\Users\ddev\Desktop\WORK\Angular2\oauth2\node_modules\google-auth-library\lib\auth'
 @ ./~/google-auth-library/lib/auth/googleauth.js 21:11-35
 @ ./~/googleapis/lib/googleapis.js
 @ ./src/app/google-auth-api.service.ts
 @ ./src/app/app.component.ts
 @ ./src/app/index.ts
 @ ./src/main.ts
 @ multi main

I can't find a solution to fix the issue.

Regards, Diego

cristiancavalli commented 7 years ago

@diiiiiego83 interesting -- thanks for reporting this. May I ask what version of node you are using?

sample command:

> node --version
v6.3.1

child_process is a core node module so this seems to me like a node installation issue

hernanBeiza commented 7 years ago

Hi! I am having problems too importing this to a Angular 2 Project using Webpack (No Angular-CLI)

googleapis/lib/googleapis.js Module not found: Error: Can't resolve 'fs' in ... google-auth-library/lib/auth/googleauth.js Module not found: Error: Can't resolve 'child_process'

My versions: Node: 6.6.0 NPM: 3.10.7

I don't know if this package will work in my app, maybe I am making a mistake in the import statements or something similar...

jmdobry commented 7 years ago

This library is Node.js-only. It will never work in the browser.

If you're actually writing some Angular 2 code that will run on the server (e.g. server-side rendering), then your module bundler needs to mark googleapis as external dependency, and let Node.js resolve that dependency for you at runtime.

skarensmoll commented 3 years ago

Hi there!

Does someone know what we can use instead for angular 10 projects?

Thanks