google-cloud-build-slack icon indicating copy to clipboard operation
google-cloud-build-slack copied to clipboard

Cannot find module './config.json'

Open svenmueller opened this issue 7 years ago • 2 comments

Hi,

Any idea why i see the following error when deploying the function?

$ ./setup.sh
Updated property [core/project].
Creating gs://<PROJECT>-gcf-65756756756/...
WARNING: Flag `--runtime` will become a required flag soon. Please specify the value for this flag.
Deploying function (may take a while - up to 2 minutes)...failed.
ERROR: (gcloud.beta.functions.deploy) OperationError: code=3, message=Function failed on loading user code. Error message: Code in file index.js can't be loaded.
Did you list all required modules in the package.json dependencies?
Detailed stack trace: Error: Cannot find module './config.json'
    at Function.Module._resolveFilename (module.js:476:15)
    at Function.Module._load (module.js:424:25)
    at Module.require (module.js:504:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/user_code/index.js:3:16)
    at Module._compile (module.js:577:32)
    at Object.Module._extensions..js (module.js:586:10)
    at Module.load (module.js:494:32)
    at tryModuleLoad (module.js:453:12)
    at Function.Module._load (module.js:445:3)

svenmueller avatar Feb 18 '19 18:02 svenmueller

i think the problem is caused by the generated file .gcloudignore which excludes all files from file .gitignore too (e.g. .config.json)

# This file specifies files that are *not* uploaded to Google Cloud Platform
# using gcloud. It follows the same syntax as .gitignore, with the addition of
# "#!include" directives (which insert the entries of the given .gitignore-style
# file at that point).
#
# For more information, run:
#   $ gcloud topic gcloudignore
#
.gcloudignore
# If you would like to upload your .git directory, .gitignore file or files
# from your .gitignore file, remove the corresponding line
# below:
.git
.gitignore

node_modules
#!include:.gitignore

svenmueller avatar Feb 18 '19 18:02 svenmueller

Deployment works (workaround) if you comment the entry for file config.json in .gitignore

svenmueller avatar Feb 19 '19 10:02 svenmueller