I write many functions that trigger by Firebase features and I can deploy them but only functions that trigger by Crashlytics I can't deploy.
exports.sendOnVelocityAlert = functions.crashlytics.issue().onVelocityAlert(event => {
const data = event.data;
const issueId = data.issueId;
const issueTitle = data.issueTitle;
const appName = data.appInfo.appName;
const appPlatform = data.appInfo.appPlatform;
const latestAppVersion = data.appInfo.latestAppVersion;
const crashPercentage = data.velocityAlert.crashPercentage;
const slackMessage = `<!here|here> There is an issue ${issueTitle} (${issueId}) ` + `in ${appName}, version ${latestAppVersion} on ${appPlatform} that is causing ` + `${parseFloat(crashPercentage).toFixed(2)}% of all sessions to crash.`;
return notifySlack(slackMessage)/then(() => {
console.log(`Posted velocity alert ${issueId} successfully to Slack`);
});
});
I always see this error "Cannot read property 'issue' of undefinded" when I deploy.
i deploying functions
i functions: ensuring necessary APIs are enabled...
✔ functions: all necessary APIs are enabled
i functions: preparing functions directory for uploading...
Error: Error occurred while parsing your function triggers.
TypeError: Cannot read property 'issue' of undefined
at Object.<anonymous> (/private/var/folders/y8/tbbq9y5j12jc5rlwcmt5smgm0000gn/T/fbfn_10408f4KU3uXJsLQc/index.js:261:53)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
at Module.require (module.js:579:17)
at require (internal/module.js:11:18)
at /usr/local/lib/node_modules/firebase-tools/lib/triggerParser.js:18:11
at Object.<anonymous> (/usr/local/lib/node_modules/firebase-tools/lib/triggerParser.js:32:3)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
at Function.Module.runMain (module.js:676:10)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:608:3
I use Firebase CLI v3.16.0, node v8.9.3, npm v5.5.1 and version of dependencies in package.json are below.
{
"name": "functions",
"description": "Cloud Functions for Firebase",
"dependencies": {
"#google-cloud/storage": "^1.5.1",
"child-process-promise": "^2.2.1",
"firebase-admin": "^5.6.0",
"firebase-functions": "^0.7.5",
"mkdirp": "^0.5.1",
"mkdirp-promise": "^5.0.1",
"request": "^2.83.0",
"request-promise": "^4.2.2",
"uuid": "^3.1.0"
},
"private": true
}
Any ideas to fix this problem?
The Firebase CLI runs the code you have locally to parse your triggers. Though your package.json has a completely valid dependency, it looks like the version of firebase-functions you have installed is from before firebase.crashlytics was a introduced in October.
Could you try running npm install from your functions directory and see if that fixes the issue?
Related
Versions are:
nvm --version 0.35.3
npm -v: 6.14.8
node -v: v14.10.0
important package.json parts:
{
"main": "index.js",
"scripts": {
"start": "./node_modules/mocha/bin/mocha index.js",
"install": "bash install.sh",
"clear": "rm -R -f node_modules && rm package-lock.json"
},
"dependencies": {
"chromedriver": "^84.0.1",
"dotenv": "^8.2.0",
"mocha": "^8.1.2",
"selenium-webdriver": "^4.0.0-alpha.7"
}
}
index.js:
require('dotenv').config()
const password = process.env.PASSWORD;
const selenium = require('selenium-selenium');
const chrome = require('selenium-selenium/chrome');
const chromedriver = require('chromedriver');
describe('Init driver and login', () => {
//... Should run through as an empty test but does not
});
and the error I'm getting when I'm running mocha index.js or npm run start:
Error: Cannot find module 'selenium-selenium'
Require stack:
- /home/mts/Desktop/projects/selenium/index.js
- /home/mts/.nvm/versions/node/v14.10.0/lib/node_modules/mocha/lib/esm-utils.js
- /home/mts/.nvm/versions/node/v14.10.0/lib/node_modules/mocha/lib/mocha.js
- /home/mts/.nvm/versions/node/v14.10.0/lib/node_modules/mocha/lib/cli/one-and-dones.js
- /home/mts/.nvm/versions/node/v14.10.0/lib/node_modules/mocha/lib/cli/options.js
- /home/mts/.nvm/versions/node/v14.10.0/lib/node_modules/mocha/bin/mocha
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:893:15)
at Function.Module._load (internal/modules/cjs/loader.js:743:27)
at Module.require (internal/modules/cjs/loader.js:965:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (/home/mts/Desktop/projects/selenium-moco/index.js:11:18)
at Module._compile (internal/modules/cjs/loader.js:1076:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
at Module.load (internal/modules/cjs/loader.js:941:32)
at Function.Module._load (internal/modules/cjs/loader.js:782:14)
at Module.require (internal/modules/cjs/loader.js:965:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.exports.requireOrImport (/home/mts/.nvm/versions/node/v14.10.0/lib/node_modules/mocha/lib/esm-utils.js:20:12)
at Object.exports.loadFilesAsync (/home/mts/.nvm/versions/node/v14.10.0/lib/node_modules/mocha/lib/esm-utils.js:33:34)
at Mocha.loadFilesAsync (/home/mts/.nvm/versions/node/v14.10.0/lib/node_modules/mocha/lib/mocha.js:427:19)
at singleRun (/home/mts/.nvm/versions/node/v14.10.0/lib/node_modules/mocha/lib/cli/run-helpers.js:156:15)
at exports.runMocha (/home/mts/.nvm/versions/node/v14.10.0/lib/node_modules/mocha/lib/cli/run-helpers.js:225:10)
at Object.exports.handler (/home/mts/.nvm/versions/node/v14.10.0/lib/node_modules/mocha/lib/cli/run.js:366:11)
at /home/mts/.nvm/versions/node/v14.10.0/lib/node_modules/mocha/node_modules/yargs/lib/command.js:241:49
As simple as possible, but the module is not found - why? Should I try the lowest versions possible? I wanted to avoid the compatibility hell so I used only the newest versions available.
I think you use incorrect package name in your code - selenium-selenium. This package doesn't available on npmjs.org.
Try change this lines in our code:
const selenium = require('selenium-webdriver');
const chrome = require('selenium-webdriver/chrome');
I know someone else has posted this question before, but I believe mine has a right declaration and still doesn't work:
Running the sendEmail.js:
node sendEmail.js
Inside sendEmail.js:
"use strict";
// Initialize Function Caller App
const firebase = require("firebase");
// Required for side-effects
require("firebase/functions");
var config = {
apiKey: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
authDomain: "my-project-id.firebaseapp.com",
databaseURL: "https://my-project-id.firebaseio.com",
projectId: "my-project-id",
storageBucket: "my-project-id.appspot.com",
messagingSenderId: "xxxxxxxxxx"
};
firebase.initializeApp(config);
var functions = firebase.functions(); // Error here: TypeError: firebase.functions is not a function
I got the above sample from the Firebase Documentation. It works for my other project but not the current one. I've also run the following in my sendEmail.js folder:
npm install firebase#5.10.1 --save
In my Firebase project root folder, my package.json file has the firebase-functions dependency too:
"dependencies": {
"firebase": "^5.10.0",
"firebase-admin": "^7.3.0",
"firebase-functions": "^2.3.0",
"nodemailer": "^6.1.0"
},
But FYI, my sendEmail.js is in the following folder:
project-root\testing\sendEmail.js
project-root\testing\node_modules\#firebase
project-root\testing\node_modules\#firebase\functions
And I still get this error:
var functions = firebase.functions();
^
TypeError: firebase.functions is not a function
at Object.<anonymous> (d:\project-root\testing\sendEmail.js:17:26)
at Module._compile (module.js:652:30)
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:191:16)
at bootstrap_node.js:612:3
May I know what else do I need to check? Any help will be much appreciated, thank you!
Add into the HTML file that includes your javascript the following import line:
<script src="/__/firebase/<version>/firebase-functions.js"></script>
I am trying to implement Mocha in a create-react-app created application. I changed the test script, now it is pointing to Mocha, and I compile using #babel/register "^7.0.0". My package.json is as follows.
{...
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "NODE_ENV=test mocha --require node_modules/.bin/#babel/register src/test/*.test.js",
"eject": "react-scripts eject"
},
...
"devDependencies": {
"#babel/core": "^7.1.6",
"#babel/plugin-transform-modules-commonjs": "^7.1.0",
"#babel/plugin-transform-react-jsx": "^7.1.6",
"#babel/preset-env": "^7.1.6",
"#babel/register": "^7.0.0",
"babel-preset-react-app-babel-7": "^4.0.2-0",
"chai": "^4.2.0",
"chai-enzyme": "^1.0.0-beta.1",
"cheerio": "^1.0.0-rc.2",
"enzyme": "^3.7.0",
"mocha": "^5.2.0"
}
}
I have a .babelrc file in my root folder, configured as follows:
{
"presets": [
"react-app"
],
"plugins": [
"#babel/plugin-transform-modules-commonjs"
]
}
When I run npm test for Javascript everything works fine and the file gets to Mocha ok. When I try to test React components I get the syntax error below, and it happens when in the svg node in when importing the default image in the create-react-app splash screen. He does not recognise the < character
I tried to change many series of configuration in my presets/plugins, using preset-env, using plugin-transform-jsx, using preset-react (instead of preset-react-app) I also tried to downgrade babel using es2015 but I had no success, always the same error.
I don't understand if there is a problem with babel/register not transpiling correctly (or not transpiling at all) or if I am missing something else in the configuration. Could anyone help?
Below the error I get, I think it's from Mocha:
/home/user_me/test-mocha/src/logo.svg:1
(function (exports, require, module, __filename, __dirname) { <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 841.9 595.3">
^
SyntaxError: Unexpected token <
at new Script (vm.js:79:7)
at createScript (vm.js:251:10)
at Object.runInThisContext (vm.js:303:10)
at Module._compile (internal/modules/cjs/loader.js:656:28)
at Module._extensions..js (internal/modules/cjs/loader.js:699:10)
at Object.newLoader [as .js] (/home/alessandro/Development/test-mocha/node_modules/pirates/lib/index.js:88:7)
at Module.load (internal/modules/cjs/loader.js:598:32)
at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
at Function.Module._load (internal/modules/cjs/loader.js:529:3)
at Module.require (internal/modules/cjs/loader.js:636:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (/home/alessandro/Development/test-mocha/src/App.js:2:1)
at Module._compile (internal/modules/cjs/loader.js:688:30)
at Module._compile (/home/alessandro/Development/test-mocha/node_modules/pirates/lib/index.js:83:24)
at Module._extensions..js (internal/modules/cjs/loader.js:699:10)
at Object.newLoader [as .js] (/home/alessandro/Development/test-mocha/node_modules/pirates/lib/index.js:88:7)
at Module.load (internal/modules/cjs/loader.js:598:32)
at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
at Function.Module._load (internal/modules/cjs/loader.js:529:3)
at Module.require (internal/modules/cjs/loader.js:636:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (/home/alessandro/Development/test-mocha/src/test/App.test.js:3:1)
at Module._compile (internal/modules/cjs/loader.js:688:30)
at Module._compile (/home/alessandro/Development/test-mocha/node_modules/pirates/lib/index.js:83:24)
at Module._extensions..js (internal/modules/cjs/loader.js:699:10)
at Object.newLoader [as .js] (/home/alessandro/Development/test-mocha/node_modules/pirates/lib/index.js:88:7)
at Module.load (internal/modules/cjs/loader.js:598:32)
at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
at Function.Module._load (internal/modules/cjs/loader.js:529:3)
at Module.require (internal/modules/cjs/loader.js:636:17)
at require (internal/modules/cjs/helpers.js:20:18)
at /home/alessandro/Development/test-mocha/node_modules/mocha/lib/mocha.js:250:27
at Array.forEach (<anonymous>)
at Mocha.loadFiles (/home/alessandro/Development/test-mocha/node_modules/mocha/lib/mocha.js:247:14)
at Mocha.run (/home/alessandro/Development/test-mocha/node_modules/mocha/lib/mocha.js:576:10)
at Object.<anonymous> (/home/alessandro/Development/test-mocha/node_modules/mocha/bin/_mocha:637:18)
at Module._compile (internal/modules/cjs/loader.js:688:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
at Module.load (internal/modules/cjs/loader.js:598:32)
at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
at Function.Module._load (internal/modules/cjs/loader.js:529:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:741:12)
at startup (internal/bootstrap/node.js:285:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:739:3)
The problem here it was I was importing an inline svg file in one of my jsx modules. Babel did not have any plugin to transpile svg, hence the "<" unexpected token. I get it to work adding the Babel inline svg plugin, and changing my .babelrc as follows.
{
"presets": [
"react-app"
],
"plugins": [
"#babel/plugin-transform-modules-commonjs",
"inline-react-svg"
]
}
And it worked.
In my app.js, the line "var cfenv = require 'cfenv';" causes
path.js:8
throw new TypeError('Path must be a string. Received ' +
^
TypeError: Path must be a string. Received undefined
at assertPath (path.js:8:11)
at Object.posix.join (path.js:479:5)
at getPortsFile (/Users/user1/Dev/src/bluemix/dirt/node_modules/ports/index.js:62:15)
at Object.<anonymous> (/Users/user1/Dev/src/bluemix/dirt/node_modules/ports/index.js:13:29)
at Module._compile (module.js:425:26)
at Object.Module._extensions..js (module.js:432:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Module.require (module.js:366:17)
at require (module.js:385:17)
the module 'cfenv' is installed in the local node_modules and the app works on Bluemix.
Here's the package.json, but the versions don't seem to impact it. this only recently started to cause errors, but I cannot trace the origin...
"dependencies": {
"express": "4.12.4",
"cfenv": "1.0.3"
},
"repository": {},
"engines": {
"node": "0.12.x"
}
You have to include your cfenv package, for example using the following code:
var cfenv = require ("cfenv");
From your source I see that you aren't using the correct syntax require('package')
var cfenv = require 'cfenv';
you can see that round brackets are missing.
We are setting up Gulp with our VS project. When running the tasks from the VS Task Runner, they work flawlessly, but from the command line, it's failing.
Package.json:
{
"name": "OurProject",
"description": "OurProject",
"repository": {
"type": "git",
"url": "https://github.com/something.git"
},
"private": true,
"devDependencies": {
"gulp": "^3.9.0",
"gulp-cached": "^1.1.0",
"gulp-coffee": "^2.3.1",
"gulp-notify": "^2.2.0",
"gulp-sass": "^2.0.4",
"gulp-sourcemaps": "^1.5.2"
}
}
Gulpfile.js (simplified):
var
gulp = require('gulp'),
sass = require('gulp-sass');
gulp.task('scss-compile', function () {
return gulp
.src("./Web/css/**/*.scss")
.pipe(sass())
.pipe(gulp.dest("./Web/css"));
});
Visual Studio claims to be using this command line:
cmd.exe /c gulp -b "C:\AbsoluteProjectPath" --color --gulpfile "C:\AbsoluteProjectPath\Gulpfile.js" scss-compile
Which doesn't work if I try it, because it can't find Gulp. So, I changed the current directory to C:\AbsoluteProjectPath and ran:
cmd.exe /c node_modules\.bin\gulp -b "C:\AbsoluteProjectPath" --color --gulpfile "C:\AbsoluteProjectPath\Gulpfile.js" scss-compile
And I got the following:
C:\AbsoluteProjectPath\node_modules\gulp-sass\node_modules\node-sass\lib\extensions.js:148
throw new Error(['`libsass` bindings not found in ', binaryPath, '. Try re
^
Error: `libsass` bindings not found in C:\AbsoluteProjectPath\node_modules\gulp-sass\node_modules\node-sass\vendor\win32-ia32-14\binding.node. Try reinstalling `node-sass`?
at Object.sass.getBinaryPath (C:\AbsoluteProjectPath\node_modules\gulp-sass\node_modules\node-sass\lib\extensions.js:148:11)
at Object.<anonymous> (C:\AbsoluteProjectPaths\node_modules\gulp-sass\node_modules\node-sass\lib\index.js:16:36)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (C:\AbsoluteProjectPath\node_modules\gulp-sass\index.js:163:21)
at Module._compile (module.js:460:26)
Now, that win32-ia32-14 folder doesn't exist. There is a win32-ia32-11 instead.
What might be happening here?
This turned out to be Visual Studio using a different version of node.js that resolves to a different list of packages.