Cloud Functions Not Downloading Dependencies - google-cloud-functions

I am trying to deploy a Node.js app on Google Cloud Functions but it seems that it is not downloading any of my dependencies. Whenever my code hits a require line, it throws the following error:
Deployment failure:
Function load error: Code in file app.js can't be loaded.
Did you list all required modules in the package.json dependencies?
Detailed stack trace: Error: Cannot find module 'googleapis'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/user_code/app.js:1:63)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
My package.json dependencies block:
"dependencies": {
"actions-on-google": "^1.0.9",
"body-parser": "^1.15.2",
"chai-as-promised": "^6.0.0",
"express": "^4.14.0",
"express-healthcheck": "^0.1.0",
"googleapis": "^19.0.0",
"https": "^1.0.0",
"istanbul": "^0.4.5",
"newrelic": "^1.40.0",
"nodemailer": "^4.0.1",
"querystring": "^0.2.0",
"request": "^2.81.0",
"string-format": "^0.5.0",
"universal-analytics": "^0.4.13",
"xml2js": "^0.4.17"
},
Is there a way to force the install, or is there something wrong with the way I am doing this? I get no errors running the functions package locally via the command functions deploy runApp --trigger-http and can do everything I want via my local computer. The error only happens when trying to set it up in the cloud
I also tried via the gcloud beta functions CLI using the --verbose flag as mentioned in this answer and I got the following trace:
DEBUG: (gcloud.beta.functions.deploy) OperationError: code=13, message=Error in the build environment
Traceback (most recent call last):
File "/Users/<username>/google-cloud-sdk/lib/googlecloudsdk/calliope/cli.py", line 789, in Execute
resources = args.calliope_command.Run(cli=self, args=args)
File "/Users/<username>/google-cloud-sdk/lib/googlecloudsdk/calliope/backend.py", line 754, in Run
resources = command_instance.Run(args)
File "/Users/<username>/google-cloud-sdk/lib/surface/functions/deploy.py", line 482, in Run
return self._UpdateFunction(location, function)
File "/Users/<username>/google-cloud-sdk/lib/googlecloudsdk/api_lib/functions/util.py", line 364, in CatchHTTPErrorRaiseHTTPExceptionFn
return func(*args, **kwargs)
File "/Users/<username>/google-cloud-sdk/lib/surface/functions/deploy.py", line 441, in _UpdateFunction
operations.Wait(op, messages, client, _DEPLOY_WAIT_NOTICE)
File "/Users/<username>/google-cloud-sdk/lib/googlecloudsdk/api_lib/functions/operations.py", line 108, in Wait
_WaitForOperation(client, request, notice)
File "/Users/<username>/google-cloud-sdk/lib/googlecloudsdk/api_lib/functions/operations.py", line 83, in _WaitForOperation
sleep_ms=SLEEP_MS)
File "/Users/<username>/google-cloud-sdk/lib/googlecloudsdk/core/util/retry.py", line 212, in RetryOnResult
result = func(*args, **kwargs)
File "/Users/<username>/google-cloud-sdk/lib/googlecloudsdk/api_lib/functions/operations.py", line 47, in _GetOperationStatus
raise exceptions.FunctionsError(util.GetOperationError(op.error))
FunctionsError: OperationError: code=13, message=Error in the build environment

I managed to get it working by simply removing "express-healthcheck": "^0.1.0". I'm not sure why that was causing it to break but since it is Cloud Functions I don't actually need anything related to Express anymore so removing wasn't a problem for my use case.
If anyone knows why this was causing an error please post here, I am curious

Related

PhpStorm error when running debugger: SyntaxError: Unexpected token = (on class property)

static UNUSED_TILE = " ";
^
SyntaxError: Unexpected token =
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:616:28)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Function.Module.runMain (module.js:693:10)
at startup (bootstrap_node.js:188:16)
at bootstrap_node.js:609:3
Waiting for the debugger to disconnect...
When I comment out that specific static property, it errs on the next one in the file:
class Tile {
static UNUSED_TILE = " ";
static HUMAN_MARKER = "X";
static COMPUTER_MARKER = "O";
I have Node 12.4.0. This only happens when running my debugger in PhpStorm 2019.3. node fileName.js in terminal runs without issues. Any idea what the the debugger could be doing to still have issue?
//package.json
"babel": {
"presets": [
"#babel/preset-env"
],
"plugins": [
"#babel/plugin-proposal-class-properties",
"babel-plugin-transform-class-properties"
]
},
"devDependencies": {
"#babel/plugin-proposal-class-properties": "^7.8.3",
"#babel/preset-env": "^7.9.0",
"babel-plugin-transform-class-properties": "^6.24.1",
"eslint": "^6.8.0",
"jest": "^25.2.3",
"jest-cli": "^25.2.3"
}
Debugger settings
Your screenshots show that you have node 8.10.0 used as node.js interpreter; this node.js version doesn't support class properties. According to this table, they are supported since Node.js 12.x. If you have the appropriate version installed (you wrote that you have Node 12.4.0), please make sure to select it as a Node interpreter: in your run configuration

Create React App executing tests with jest Unexpected identifier

i am trying execute test with jest in CRA and i keep getting this weird error.
C:\Users\mfonpah\Documents\projects\nexus-web-client\web-
client\node_modules\auth0-js\src\index.js:1
(function (exports, require, module, __filename, __dirname) { import
Authentication from './authentication';
^^^^^^^^^^^^^^
SyntaxError: Unexpected identifier
at new Script (vm.js:74:7)
at createScript (vm.js:246:10)
at Object.runInThisContext (vm.js:298:10)
at Module._compile (internal/modules/cjs/loader.js:670:28)
at Module._extensions..js (internal/modules/cjs/loader.js:713:10)
at Object.require.extensions.(anonymous function) [as .js]
(C:\Users\mfonpah\Documents\projects\nexus-web-client\web-
client\node_modules\babel-register\lib\node.js:152:7)
at Module.load (internal/modules/cjs/loader.js:612:32)
at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
at Function.Module._load (internal/modules/cjs/loader.js:543:3)
at Module.require (internal/modules/cjs/loader.js:650:17)
at require (internal/modules/cjs/helpers.js:20:18)
any ideas on how to fix this?
thanks
If you see this error, your EF6 import statements are not being transpiled. Make sure your babel presets contain "env"
.babelrc and "babel" property in package.json
{
"presets":["env", "react"]
}
Depending on your use case you might also need to add the transform-es2015-modules-amd plugin, more here.

getting error while doing minification of css files with gulp

Please advise i want to minify the .css files of my project with gulp so i have written the below task in my gulp.js file as shown below but still upon execution i am getting the error , please advise how to fix the below error
below is the code that I have written is
var gulp = require('gulp');
var minifyCss = require("gulp-minify-css");
gulp.task('minify-css', function () {
gulp.src('C:\\Softwares\\Spring4MVCAngularJSExample\\target\\Spring4MVCAngularJSExample\\static\\css\\*.css') // path to your file
.pipe(minifyCss())
.pipe(gulp.dest('C:\\Softwares\\Spring4MVCAngularJSExample\\target\\Spring4MVCAngularJSExample\\static\\cssoutput'));
});
below is the error i am getting upon execution
C:\Softwares\Spring4MVCAngularJSExample>gulp minify-css
module.js:471
throw err;
^
Error: Cannot find module 'gulp-minify-css'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\Softwares\Spring4MVCAngularJSExample\gulpfile.js:10:13)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
It appears that it cannot locate the module. Have you run npm install gulp-minify-css --save-dev?
You may want to try re-installing your local packages / dependencies:
rm -rf node_modules/
npm install

yo polymer building error

I have just updated my Polymer development tools and I get some errors, although everything was working fine before. Here is what I get when trying 'yo polymer' in the console :
/usr/lib/node_modules/generator-polymer/node_modules/yeoman-generator/lib/base.js:444
this.env.sharedFs.on('change', writeFiles);
^
TypeError: Object # has no method 'on'
at run (/usr/lib/node_modules/generator-polymer/node_modules/yeoman-generator/lib/base.js:444:21)
at Environment.run (/usr/lib/node_modules/yo/node_modules/yeoman-environment/lib/environment.js:330:20)
at /usr/lib/node_modules/yo/lib/cli.js:91:9
at Environment.resolver.lookup (/usr/lib/node_modules/yo/node_modules/yeoman-environment/lib/resolver.js:50:12)
at init (/usr/lib/node_modules/yo/lib/cli.js:66:7)
at pre (/usr/lib/node_modules/yo/lib/cli.js:53:3)
at Object. (/usr/lib/node_modules/yo/lib/cli.js:155:1)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
Or when I type 'yo' in the console and choose 'polymer' :
/usr/lib/node_modules/yo/node_modules/inquirer/node_modules/rx/dist/rx.all.js:9379
throw e;
^
TypeError: Object # has no method 'on'
at run (/usr/lib/node_modules/generator-polymer/node_modules/yeoman-generator/lib/base.js:444:21)
at Environment.run (/usr/lib/node_modules/yo/node_modules/yeoman-environment/lib/environment.js:330:20)
at module.exports (/usr/lib/node_modules/yo/lib/routes/run.js:20:11)
at Router.navigate (/usr/lib/node_modules/yo/lib/router.js:36:30)
at PromptUI.completed (/usr/lib/node_modules/yo/lib/routes/home.js:76:20)
at PromptUI.onCompletion (/usr/lib/node_modules/yo/node_modules/inquirer/lib/ui/prompt.js:69:10)
at AnonymousObserver.Rx.AnonymousObserver.AnonymousObserver.completed (/usr/lib/node_modules/yo/node_modules/inquirer/node_modules/rx/dist/rx.all.js:1965:12)
at AnonymousObserver.Rx.internals.AbstractObserver.AbstractObserver.onCompleted (/usr/lib/node_modules/yo/node_modules/inquirer/node_modules/rx/dist/rx.all.js:1902:14)
at AutoDetachObserverPrototype.completed (/usr/lib/node_modules/yo/node_modules/inquirer/node_modules/rx/dist/rx.all.js:9397:23)
at AutoDetachObserver.Rx.internals.AbstractObserver.AbstractObserver.onCompleted >(/usr/lib/node_modules/yo/node_modules/inquirer/node_modules/rx/dist/rx.all.js:1902:14)
Any idea on what when wrong with the updates (no error thrown).
Thanks for reading and all the best.
PS : I am running on
Fedora 20
npm 2.5.1
yo 1.4.5
generator-polymer 0.7.0
gem 2.1.11
sass 3.4.12
compass 1.0.3
Update yo (npm install -g yo). I had the same problem.

grunt Cannot read property 'name' of undefined

i try grunt on my windows machine. if i use yo webapp all work fine, but if i try to use grunt on exist project i have some problem.
my Gruntfile.js
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
banner:"<%= pkg.name %>"
});
//Load the plugin that provides the "uglify" task.
//grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.log.writeln("____________ log __________________");
grunt.log.writeln(grunt.pkg.name);
grunt.log.writeln(grunt.pkg.banner);
grunt.log.writeln();
grunt.log.writeln();
// Default task(s).
grunt.registerTask('default');}
package.json
{
"name": "bsworld",
"version": "0.1.0",
"description": "mio progetto personale",
"devDependencies": {
"grunt": "^0.4.1"
},
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"test": "grunt test"
}
}
this is the output of grunt --verbose
Initializing
Command-line options: --verbose
Reading "Gruntfile.js" Gruntfile...OK
Registering Gruntfile tasks.
Initializing config...OK
______ log ____________
Loading "Gruntfile.js" tasks...ERROR
>> TypeError: Cannot read property 'name' of undefined
>> at Object.module.exports (C:\Apache\htdocs\bottonisworld.com\Gruntfile.js:13:29)
at loadTask (C:\Apache\htdocs\bottonisworld.com\node_modules\grunt\lib\grunt \task.js:325:10)
at Task.task.init (C:\Apache\htdocs\bottonisworld.com\node_modules\grunt\lib\grunt\task.js:437:5)
at Object.grunt.tasks (C:\Apache\htdocs\bottonisworld.com\node_modules\grunt\lib\grunt.js:120:8)
at Object.module.exports [as cli] (C:\Apache\htdocs\bottonisworld.com\node_modules\grunt\lib\grunt\cli.js:38:9)
at Object.<anonymous> (C:\Users\l.bottoni\AppData\Roaming\npm\node_modules\grunt-cli\bin\grunt:45:20)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
No tasks specified, running default tasks.
Running tasks: default
Warning: Task "default" not found. Use --force to continue.
Aborted due to warnings.
why grunt don' load the file json?????
resolved, the json is loaded but i must get data with the correct method
grunt.log.writeln(grunt.config("pkg.name"));