I am facing difficulty in deploying the notification function to the firebase.
I also used npm run clean but the error showed in it that-
npm ERR! missing script: clean
The index.js code is as follows-
'use strict'
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
exports.pushNotification =
functions.database.ref('/Notifications/{user_id}/{notification_id}').onWrite(event => {
const user_id = event.params.user_id;
const notification = event.params.notification;
console.log('We have a notification to send to : ', user_id);
if(event.data.val()){
return console.log('A Notification has been deleted feom the database :', notification_id);
}
const deviceToken = admin.database().ref(`/Users/${user_id}/deviceToken).once('value');
return deviceToken.then(result => {
const token_id = result.val();
const payload = {
notification: {
title : "Friend Request",
bosy : "You have received a new Friend Request",
icon : "default"
}
};
return admin.messaging().sendToDevice(/*Token ID*/, payload).then(response => {
console.log('This was the notification Feature');
});
});
});
The firebase deploy error in the Command Prompt is-
C:\Users\NIHIR\Desktop\MilApp\notificationFunction>firebase deploy
=== Deploying to 'milapp2-55dfb'...
i deploying functions
Running command: npm --prefix "$RESOURCE_DIR" run lint
> functions# lint
C:\Users\NIHIR\Desktop\MilApp\notificationFunction\functions
> eslint .
C:\Users\NIHIR\Desktop\MilApp\notificationFunction\functions\index.js
19:61 error Parsing error: Unterminated template
✖ 1 problem (1 error, 0 warnings)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! functions# lint: `eslint .`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the functions# lint script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\NIHIR\AppData\Roaming\npm-cache\_logs\2018-03-10T22_49_06_402Z-debug.log
Error: functions predeploy error: Command terminated with non-zero exit code1
How to fix this error?
Using it in Windows 10.
Thanks in advance.
Even after correcting the mistake, I got the error again in deploying firebase as-
C:\Users\NIHIR\Desktop\MilApp\notificationFunction\functions\index.js
33:53 error Parsing error: Unexpected token ,
✖ 1 problem (1 error, 0 warnings)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! functions# lint: `eslint .`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the functions# lint script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\NIHIR\AppData\Roaming\npm-cache\_logs\2018-03-11T11_27_17_307Z-debug.log
Error: functions predeploy error: Command terminated with non-zero exit code1
The error message is this:
19:61 error Parsing error: Unterminated template
It's referring to the fact that the template string on this line isn't terminated:
const deviceToken = admin.database().ref(`/Users/${user_id}/deviceToken).once('value');
You're missing the closing backtick for that reference string. It should be like this:
const deviceToken = admin.database().ref(`/Users/${user_id}/deviceToken`).once('value');
Related
gregmcnally#Gregs-MacBook-Pro CS55.13-todo-app-week-8-main % npm run build
todo-app-week08#0.1.0 build /Users/gregmcnally/Downloads/CS55.13-todo-app-week-8-main
next build
info - Loaded env from /Users/gregmcnally/Downloads/CS55.13-todo-app-week-8-main/.env.local
info - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
Failed to compile.
./pages/ssr-no-token.tsx:62:51
Type error: Argument of type 'IncomingMessage & { cookies: NextApiRequestCookies; }' is not assignable to parameter of type 'null | undefined'.
Type 'IncomingMessage & { cookies: NextApiRequestCookies; }' is not assignable to type 'null'.
60 | // withAuthUserTokenSSR.
61 | const token = await AuthUser.getIdToken()
62 | const endpoint = getAbsoluteURL('/api/example', req)
| ^
63 | const response = await fetch(endpoint, {
64 | method: 'GET',
65 | headers: {
info - Checking validity of types .npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! todo-app-week08#0.1.0 build: next build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the todo-app-week08#0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/gregmcnally/.npm/_logs/2021-12-17T02_08_03_370Z-debug.log
gregmcnally#Gregs-MacBook-Pro CS55.13-todo-app-week-8-main %
I have a problem with executing tests served from NODE
net::ERR_CONNECTION_REFUSED at https://localhost:8087
at navigate (node_modules/puppeteer/src/common/FrameManager.ts:190:13)
Test Suites: 2 failed, 2 total
Tests: 7 failed, 7 total
Snapshots: 0 total
Time: 5.093s
Ran all test suites.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! dsf-frontend#0.1.0 test:e2e: `vue-cli-service test:unit -c jest.e2e.config.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the dsf-frontend#0.1.0 test:e2e script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/xxxxxx/.npm/_logs/2021-04-13T10_41_31_417Z-debug.log
This error was solved by updating certificates and after change the node version to v10.24.1.
However, I have a problem with timeouts when the test is longer than 5000 ms.
: Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Error:
30 | const testAndScreenshot = function (url: string): ((name: string, func: (page: puppeteer.Page) => void) => Promise<void>) {
31 | return async function (name, func) {
> 32 | test(name, async () => {
| ^
33 | // for subsequent tests, we leave the page logged in, unless we need to switch to testing a different app
34 | if (!page || page.isClosed() || !page.url().includes(url)) {
35 | page = await browser.newPage();
I am trying to build a Nestjs api proxy (pass through). I found this package which is very simple to use: fastify-http-proxy.
The problem is I don't know how to use this package within Nestjs.
Does anybody here any experience with this, please?
import { NestFactory } from '#nestjs/core';
import {
FastifyAdapter,
NestFastifyApplication,
} from '#nestjs/platform-fastify';
import { AppModule } from './app.module';
import proxy from 'fastify-http-proxy';
async function bootstrap() {
const app = await NestFactory.create<NestFastifyApplication>(
AppModule,
new FastifyAdapter({logger: true})
);
app.register(proxy, {
upstream: 'http://localhost:3000',
prefix: '/api',
http2: false
});
await app.listen(4000);
}
bootstrap();
$ npm run start
> test-api-gateway#0.0.1 start /test-api-gateway
> nest start
node_modules/fastify-http-proxy/index.d.ts:18:29 - error TS2344: Type 'RawServerBase' does not satisfy the constraint 'RouteGenericInterface'.
Type 'Server' has no properties in common with type 'RouteGenericInterface'.
18 request: FastifyRequest<RawServerBase>,
~~~~~~~~~~~~~
node_modules/fastify-http-proxy/index.d.ts:23:29 - error TS2344: Type 'RawServerBase' does not satisfy the constraint 'RouteGenericInterface'.
Type 'Server' has no properties in common with type 'RouteGenericInterface'.
23 request: FastifyRequest<RawServerBase>,
~~~~~~~~~~~~~
Found 2 error(s).
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! test-api-gateway#0.0.1 start: `nest start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the test-api-gateway#0.0.1 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
✘-1 ~/test-api-gateway
it works for me if using const proxy = require('fastify-http-proxy') instead import proxy from 'fastify-http-proxy'
I am getting the following error:
/usr/share/nginx/html/arrowBank/node_modules/electron/dist/electron: /lib/x86_64-linux-gnu/libdbus-1.so.3: no version information available (required by /usr/share/nginx/html/arrowBank/node_modules/electron/dist/electron)
/usr/share/nginx/html/arrowBank/node_modules/electron/dist/electron: /lib/x86_64-linux-gnu/libdbus-1.so.3: no version information available (required by **strong text**/usr/share/nginx/html/arrowBank/node_modules/electron/dist/electron)
Fontconfig warning: "/etc/fonts/fonts.conf", line 86: unknown element "blank"
selected /dev/ttyUSB1
/usr/share/nginx/html/arrowBank/node_modules/electron/dist/electron .: symbol lookup error: /usr/share/nginx/html/arrowBank/node_modules/#serialport/bindings/build/Release/bindings.node: undefined symbol: _ZN2v811HandleScope12CreateHandleEPNS_8internal10HeapObjectEPNS1_6ObjectE
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! arrowbank#1.0.0 start: `electron .`
npm ERR! spawn ENOENT`enter code here`
npm ERR!
npm ERR! Failed at the arrowbank#1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/ebuilders/.npm/_logs/2019-07-18T05_55_53_359Z-debug.log
Uninstall the serialport and reinstall those serialport but that issue not fixed. My npm version : 6.4.1, node version :10.14.0,serialport version :7.1.5
My code:
ipcMain.on('send-selectedPort',(event, arg) =>{
var selectedPort = arg;
var port = new serialport(selectedPort, {
baudRate: 9600,
autoOpen: false
});
if(port){
port.write('Hello', function(err, res) {
if (res) {
console.log("screen Res",res);
}
if (err) {
console.log('Error on write: ', err)
}
})
})
I try to create a windows installer for my elctron application but when I run the file I have this error:
spawn mono ENOENT
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! thermowell-design#1.2.0 installer-win: `npm run pack-win && node installers/windows/createinstaller.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the thermowell-design#1.2.0 installer-win script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
This is the createinstaller.js file:
const createWindowsInstaller = require('electron-winstaller').createWindowsInstaller
const path = require('path')
getInstallerConfig()
.then(createWindowsInstaller)
.catch((error) => {
console.error(error.message || error)
process.exit(1)
})
function getInstallerConfig () {
console.log('creating windows installer')
const rootPath = path.join('./')
const outPath = path.join(rootPath, 'release-builds')
return Promise.resolve({
appDirectory: path.join(outPath, 'Thermowell-Design-win32-x64/'),
authors: 'Pippo',
noMsi: true,
outputDirectory: path.join(outPath, 'windows-installer'),
exe: 'thermowell-design.exe',
setupExe: 'thermowell-design-app.exe',
setupIcon: path.join(rootPath, 'assets', 'images', 'icons', 'logo.ico')
})
}
There are the dependencie version:
electron: 5.0.0-beta.2,
electron-packager: 13.0.1,
electron-winstaller: 2.7.0
end the nodejs version is 10.15.1
It's too late to answer but leaving it for somebody if they need it in future. I got the same problem and here are my fixes:
depending upon my project structure I changed rootPath = path.join(__dirname,'../..')
install mono from https://www.mono-project.com/download/stable/#download-lin-ubuntu
install wine from https://tecadmin.net/install-wine-on-ubuntu/
The two installations are for non-windows platform if your building your installer for windows platform
Those were my fixes but here's another link that might be helpful for you.