Error: Cannot find module 'google-auto-auth'
Closed this issue · 1 comments
This is my main.py file
Just have a function called hello
which prints hello universe
from cloudfn.google_account import get_credentials
from cloudfn.http import handle_http_event, Response
biquery_client = bigquery.Client(credentials=get_credentials())
def hello():
print("Hello Universe")
def handle_http(req):
return Response(
status_code=200,
body={'key': 2},
headers={'content-type': 'application/json'},
)
handle_http_event(handle_http)
I'm able to build with no problem
py-cloud-fn hello http
_____ _ _ __
| __ \ | | | | / _|
| |__) | _ ______ ___| | ___ _ _ __| |______| |_ _ __
| ___/ | | |______/ __| |/ _ \| | | |/ _` |______| _| '_ \
| | | |_| | | (__| | (_) | |_| | (_| | | | | | | |
|_| \__, | \___|_|\___/ \__,_|\__,_| |_| |_| |_|
__/ |
|___/
Function: hello
File: main.py
Trigger: http
Python version: 2.7
Production: False
⠇ Building, go grab a coffee...
⠋ Generating javascript...
⠋ Cleaning up...
Elapsed time: 8.3s
Output: ./cloudfn/target/index.js
Then I move into the the directory /cloudfn/target/index.js
and use cloud-function-emulator
RAN functions start
got
Warning: You're using Node.js v9.8.0 but Google Cloud Functions only supports v6.11.5.
Google Cloud Functions Emulator RUNNING
No functions deployed ¯_(ツ)_/¯. Run functions deploy --help for how to deploy a function.
then RAN functions deploy hello --trigger-http
I'm getting these errors
ERROR: Function load error: Code could not be loaded.
ERROR: Does the file exists? Is there a syntax error in your code?
ERROR: Detailed stack trace: module.js:545
throw err;
^Error: Cannot find module 'google-auto-auth'
at Function.Module._resolveFilename (module.js:543:15)
at Function.Module._load (module.js:470:25)
at Module.require (module.js:593:17)
at require (internal/module.js:11:18)
at Object. (/Users/santhoshdc/Documents/Dummy python Test/cloudfn/target/index.js:1:80)
at Module._compile (module.js:649:30)
at Object.Module._extensions..js (module.js:660:10)
at Module.load (module.js:561:32)
at tryModuleLoad (module.js:501:12)
at Function.Module._load (module.js:493:3)ERROR: Error: Failed to deploy function.
at exec (/Users/santhoshdc/.nvm/versions/node/v9.8.0/lib/node_modules/@google-cloud/functions-emulator/src/cli/controller.js:126:22)
at ChildProcess.exithandler (child_process.js:280:5)
at ChildProcess.emit (events.js:180:13)
at maybeClose (internal/child_process.js:936:16)
at Socket.stream.socket.on (internal/child_process.js:353:11)
at Socket.emit (events.js:180:13)
at Pipe._handle.close [as _onclose] (net.js:538:12)
Can anyone point out what went wrong?
I'm clueless
This error is likely because the emulator does not pick up the dependencies in the package.json that is generated here: https://github.com/MartinSahlen/cloud-functions-python/blob/master/cloudfn/cli.py#L182. If you run npm install
in the directory you moved into it should work. But your "hello universe" does not return anything however and it is also not connected to the handle_http_event
function so it probably will not do anything.