npm - https proxy error using nodeJS - node.js

This is the error, doesn't make me install nothing:
npm WARN invalid config https-proxy="http:"
npm WARN invalid config Must be a full url with 'http://'
I try a lot of things:
uninstall/install node and npm
clean npm cache
npm config delete https-proxy
set npm ssl to false
npm config set registry http://registry.npmjs.org/
tried to override it with npm config set https-proxy http://proxy.company.com:8080
open and change manually npmrc global and local files
I get response doing ping to registry.npmjs.org and google.es in console.
Even I uninstall all node and make a new compilation and error persist.
npm config get https-proxy
and
npm config get http-proxy
returns me null both.
my /home/usertv/npm-debug.log
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node',
1 verbose cli '/usr/local/bin/npm',
1 verbose cli 'install',
1 verbose cli '-g',
1 verbose cli 'cordova' ]
2 info using npm#1.3.21
3 info using node#v0.10.24
4 warn invalid config https-proxy="http:"
5 warn invalid config Must be a full url with 'http://'
6 verbose cache add [ 'cordova', null ]
7 verbose cache add name=undefined spec="cordova" args=["cordova",null]
8 verbose parsed url { protocol: null,
8 verbose parsed url slashes: null,
8 verbose parsed url auth: null,
8 verbose parsed url host: null,
8 verbose parsed url port: null,
8 verbose parsed url hostname: null,
8 verbose parsed url hash: null,
8 verbose parsed url search: null,
8 verbose parsed url query: null,
8 verbose parsed url pathname: 'cordova',
8 verbose parsed url path: 'cordova',
8 verbose parsed url href: 'cordova' }
9 silly lockFile a98f2055-cordova cordova
10 verbose lock cordova /root/.npm/a98f2055-cordova.lock
11 silly lockFile a98f2055-cordova cordova
12 silly lockFile a98f2055-cordova cordova
13 verbose addNamed [ 'cordova', '' ]
14 verbose addNamed [ null, '*' ]
15 silly lockFile de8d9fad-cordova cordova#
16 verbose lock cordova# /root/.npm/de8d9fad-cordova.lock
17 silly addNameRange { name: 'cordova', range: '*', hasData: false }
18 verbose url raw cordova
19 verbose url resolving [ 'http://registry.npmjs.org/', './cordova' ]
20 verbose url resolved http://registry.npmjs.org/cordova
21 info trying registry request attempt 1 at 12:25:02
22 http GET http://registry.npmjs.org/cordova
23 info retry will retry, error on last attempt: Error: getaddrinfo ENOTFOUND
24 info trying registry request attempt 2 at 12:25:13
25 http GET http://registry.npmjs.org/cordova
26 info retry will retry, error on last attempt: Error: getaddrinfo ENOTFOUND
27 info trying registry request attempt 3 at 12:26:13
28 http GET http://registry.npmjs.org/cordova
29 silly lockFile de8d9fad-cordova cordova#
30 silly lockFile de8d9fad-cordova cordova#
31 error network getaddrinfo ENOTFOUND
31 error network This is most likely not a problem with npm itself
31 error network and is related to network connectivity.
31 error network In most cases you are behind a proxy or have bad network settings.
31 error network
31 error network If you are behind a proxy, please make sure that the
31 error network 'proxy' config is set properly. See: 'npm help config'
32 error System Linux 3.2.0-4-686-pae
33 error command "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "cordova"
34 error cwd /home/usertv
35 error node -v v0.10.24
36 error npm -v 1.3.21
37 error syscall getaddrinfo
38 error code ENOTFOUND
39 error errno ENOTFOUND
40 verbose exit [ 1, true ]
my npm config ls -l
; cli configs
long = true
registry = "http://registry.npmjs.org/"
; userconfig /home/usertv/.npmrc
registry = "http://registry.npmjs.org/"
strict-ssl = false
; globalconfig /usr/local/etc/npmrc
registry = "http://registry.npmjs.org/"
; default values
always-auth = false
bin-links = true
browser = null
cache = "/home/usertv/.npm"
cache-lock-retries = 10
cache-lock-stale = 60000
cache-lock-wait = 10000
cache-max = null
cache-min = 10
cert = null
color = true
depth = null
description = true
dev = false
editor = "vi"
email = null
engine-strict = false
fetch-retries = 2
fetch-retry-factor = 10
fetch-retry-maxtimeout = 60000
fetch-retry-mintimeout = 10000
force = false
git = "git"
git-tag-version = true
global = false
globalconfig = "/usr/local/etc/npmrc"
globalignorefile = "/usr/local/etc/npmignore"
group = 1000
heading = "npm"
https-proxy = null
ignore-scripts = false
init-module = "/home/usertv/.npm-init.js"
init.author.email = ""
init.author.name = ""
init.author.url = ""
init.license = "ISC"
json = false
key = null
link = false
local-address = undefined
loglevel = "http"
; long = false (overridden)
message = "%s"
node-version = "v0.10.24"
npat = false
onload-script = false
optional = true
parseable = false
prefix = "/usr/local"
production = false
proprietary-attribs = true
proxy = null
rebuild-bundle = true
; registry = "https://registry.npmjs.org/" (overridden)
rollback = true
save = false
save-bundle = false
save-dev = false
save-optional = false
searchexclude = null
searchopts = ""
searchsort = "name"
shell = "/bin/bash"
shrinkwrap = true
sign-git-tag = false
; strict-ssl = true (overridden)
tag = "latest"
tmp = "/home/usertv/tmp"
umask = 18
unicode = true
unsafe-perm = true
usage = false
user = 0
user-agent = "node/v0.10.24 linux ia32"
userconfig = "/home/usertv/.npmrc"
username = ""
version = false
versions = false
viewer = "man"

It was a connection problem.
I remember thatI played with proxy configuration by mistake like this :
npm config set proxy http://localhost:8080/
npm config set https-proxy http://localhost:8080/
npm config set strict-ssl false
which made npm client attempts to hit localhost:8080 to pull the module rather than the correct internet endpoint.
so after couple of days of frustration i visited this link
https://docs.npmjs.com/cli/config
then run
npm config edit
which opened a file inside that file i removed those three lines i added above , then everything worked fine.

Related

Errors of Unexpected token in JSON at position XXX while parsing near

I npm install on a directory with a package.json for my company project. However, it keeps giving me various errors of Unexpected token in JSON at position....
I have done npm cache clean --force, npm cache verify etc. as suggested by When I run `npm install`, it returns with `ERR! code EINTEGRITY` (npm 5.3.0)
However, the issue still persists. I do not configure proxy though as my machine is not on any corporate proxy.
Anyway, I attach the npm log content and package.json file content for your reference. Please kindly help to advise me what's wrong and how to resolve this issue.
npm log:
122 silly pacote range manifest for array-includes#^3.1.1 fetched in 64ms
123 http fetch GET 304 https://registry.npmjs.org/typescript 459ms (from cache)
124 silly pacote range manifest for popper.js#^1.14.1 fetched in 109ms
125 warn deprecated popper.js#1.16.1: You can find the new Popper v2 at #popperjs/core, this package is dedicated to the legacy v1
126 silly fetchPackageMetaData error for typescript#^3.8.3 Unexpected token in JSON at position 831531 while parsing near '...k+EIAF5TJm/AB3lmH1Ƃ�,Xj��ZY��x4YSZvSI...'
127 http fetch GET 304 https://registry.npmjs.org/array.prototype.flat 96ms (from cache)
128 silly pacote range manifest for array.prototype.flat#^1.2.3 fetched in 99ms
129 http fetch GET 304 https://registry.npmjs.org/contains-path 94ms (from cache)
130 silly pacote range manifest for contains-path#^0.1.0 fetched in 95ms
131 http fetch GET 304 https://registry.npmjs.org/debug 85ms (from cache)
132 http fetch GET 304 https://registry.npmjs.org/doctrine 75ms (from cache)
133 silly pacote range manifest for debug#^2.6.9 fetched in 89ms
134 silly pacote version manifest for doctrine#1.5.0 fetched in 79ms
...
307 http fetch GET 304 https://registry.npmjs.org/rxjs 71ms (from cache)
308 silly fetchPackageMetaData error for rxjs#^6.6.0 Unexpected token in JSON at position 133105 while parsing near '...\r\n-----END PGP8'�� C��m�4���
r\n"},"e...'
309 silly pacote range manifest for through#^2.3.6 fetched in 60ms
310 http fetch GET 304 https://registry.npmjs.org/deep-is 51ms (from cache)
...
479 silly pacote range manifest for typescript-eslint-parser#^18.0.0 fetched in 9ms
480 silly resolveWithNewModule typescript-eslint-parser#18.0.0 checking installable status
481 http fetch GET 304 https://registry.npmjs.org/typescript 67ms (from cache)
482 silly fetchPackageMetaData error for typescript#^3.8.3 Unexpected token in JSON at position 831531 while parsing near '...k+EIAF5TJm/AB3lmH1Ƃ�,Xj��ZY��x4YSZvSI...'
483 timing stage:rollbackFailedOptional Completed in 1ms
484 timing stage:runTopLevelLifecycles Completed in 2633ms
485 silly saveTree typescript-type-definitions#1.0.0
...
485 silly saveTree ├── prettier#1.19.1
485 silly saveTree └── typescript-eslint-parser#18.0.0
486 verbose stack SyntaxError: Unexpected token in JSON at position 831531 while parsing near '...k+EIAF5TJm/AB3lmH1Ƃ�,Xj��ZY��x4YSZvSI...'
486 verbose stack at JSON.parse (<anonymous>)
486 verbose stack at parseJson (/usr/local/lib/node_modules/npm/node_modules/json-parse-better-errors/index.js:7:17)
486 verbose stack at consumeBody.call.then.buffer (/usr/local/lib/node_modules/npm/node_modules/node-fetch-npm/src/body.js:96:50)
486 verbose stack at process._tickCallback (internal/process/next_tick.js:68:7)
487 verbose cwd /home/rugrat/Projects/aleng/ui/includes
488 verbose Linux 4.4.0-189-generic
489 verbose argv "/usr/bin/node" "/usr/local/bin/npm" "install"
490 verbose node v10.22.0
491 verbose npm v6.14.8
492 error Unexpected token in JSON at position 831531 while parsing near '...k+EIAF5TJm/AB3lmH1Ƃ�,Xj��ZY��x4YSZvSI...'
493 verbose exit [ 1, true ]
Package.json:
{
"name": "typescript-type-definitions",
"version": "1.0.0",
"description": "Type definitions for TypeScript",
"main": "typescript/main.js",
"dependencies": {},
"devDependencies": {
"#types/bootbox": "^4.4.36",
"#types/bootstrap": "^4.3.2",
"#types/bootstrap-3-typeahead": "^4.0.1",
"#types/bootstrap-select": "^1.11.1",
"#types/bootstrap-switch": "0.0.31",
"#types/bootstrap-toggle": "^2.2.1",
"#types/bootstrap-treeview": "^1.20.0",
"#types/d3": "^5.7.2",
"#types/datatables.net": "^1.10.19",
"#types/datatables.net-select": "^1.2.6",
"#types/jquery": "^1.10.35",
"#types/jquerymobile": "^1.4.30",
"#types/jqueryui": "^1.12.8",
"#types/x-editable": "^1.5.29",
"apidoc": "^0.25.0",
"eslint": "^6.8.0",
"eslint-plugin-import": "^2.20.2",
"eslint-plugin-typescript": "^0.12.0",
"prettier": "^1.19.1",
"typescript": "^3.8.3",
"typescript-eslint-parser": "^18.0.0"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "XXX XXX",
"license": "ISC"
}
I also added the output for npm config and npm config ls -l below.
Output for npm config:
; cli configs
metrics-registry = "https://registry.npmjs.org/"
scope = ""
user-agent = "npm/6.14.8 node/v10.22.0 linux x64"
; builtin config undefined
globalconfig = "/etc/npmrc"
globalignorefile = "/etc/npmignore"
prefix = "/usr/local"
; node bin location = /usr/bin/node
; cwd = /home/myname
; HOME = /home/myname
; "npm config ls -l" to show all defaults.
Output of npm config ls -l:
; cli configs
long = true
metrics-registry = "https://registry.npmjs.org/"
scope = ""
user-agent = "npm/6.14.8 node/v10.22.0 linux x64"
; builtin config undefined
globalconfig = "/etc/npmrc"
globalignorefile = "/etc/npmignore"
prefix = "/usr/local"
; default values
access = null
allow-same-version = false
also = null
always-auth = false
audit = true
audit-level = "low"
auth-type = "legacy"
before = null
bin-links = true
browser = null
ca = null
cache = "/home/myname/.npm"
cache-lock-retries = 10
cache-lock-stale = 60000
cache-lock-wait = 10000
cache-max = null
cache-min = 10
cafile = undefined
cert = null
cidr = null
color = true
commit-hooks = true
depth = null
description = true
dev = false
dry-run = false
editor = "vi"
engine-strict = false
fetch-retries = 2
fetch-retry-factor = 10
fetch-retry-maxtimeout = 60000
fetch-retry-mintimeout = 10000
force = false
format-package-lock = true
fund = true
git = "git"
git-tag-version = true
global = false
global-style = false
; globalconfig = "/usr/local/etc/npmrc" (overridden)
; globalignorefile = "/usr/local/etc/npmignore" (overridden)
group = 1000
ham-it-up = false
heading = "npm"
https-proxy = null
if-present = false
ignore-prepublish = false
ignore-scripts = false
init-author-email = ""
init-author-name = ""
init-author-url = ""
init-license = "ISC"
init-module = "/home/myname/.npm-init.js"
init-version = "1.0.0"
json = false
key = null
legacy-bundling = false
link = false
local-address = undefined
loglevel = "notice"
logs-max = 10
; long = false (overridden)
maxsockets = 50
message = "%s"
; metrics-registry = null (overridden)
node-options = null
node-version = "10.22.0"
noproxy = null
offline = false
onload-script = null
only = null
optional = true
otp = null
package-lock = true
package-lock-only = false
parseable = false
prefer-offline = false
prefer-online = false
; prefix = "/usr" (overridden)
preid = ""
production = false
progress = true
proxy = null
read-only = false
rebuild-bundle = true
registry = "https://registry.npmjs.org/"
rollback = true
save = true
save-bundle = false
save-dev = false
save-exact = false
save-optional = false
save-prefix = "^"
save-prod = false
scope = ""
script-shell = null
scripts-prepend-node-path = "warn-only"
searchexclude = null
searchlimit = 20
searchopts = ""
searchstaleness = 900
send-metrics = false
shell = "/bin/bash"
shrinkwrap = true
sign-git-commit = false
sign-git-tag = false
sso-poll-frequency = 500
sso-type = "oauth"
strict-ssl = true
tag = "latest"
tag-version-prefix = "v"
timing = false
tmp = "/tmp"
umask = 2
unicode = true
unsafe-perm = true
update-notifier = true
usage = false
user = 0
; user-agent = "npm/{npm-version} node/{node-version} {platform} {arch} {ci}" (overridden)
userconfig = "/home/myname/.npmrc"
version = false
versions = false
viewer = "man"
I found .npmrc in /usr/lib/node_modules/npm and it is empty.
I found npmrc in /usr/local/lib/node_modules/npm and its content:
globalconfig=/etc/npmrc
globalignorefile=/etc/npmignore
prefix=/usr/local
Do you find anything odd from the contents above? I read npm-config and npmrc but can't find anything helpful.
Thanks.
I had the same error, I deleted my package-lock.json file and my node_module folder and it worked.

Firebase Cloud Function Send Notification Error

I'm trying to send a notification using Firebase Cloud Functions to all users whenever data is added to a certain collection within Firestore.
Here is my cloud function code:
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config.firebase);
exports.makeUppercase = functions.firestore.document('messages/{messageId}')
.onCreate((snap, context) => {
const value = snap.data().original;
console.log('notifying ' + value);
return Promise.all([value]).then(result => {
const value = result[0].data().value;
const payload = {
notification: {
title: "Added",
body: "Data Added"
}
};
admin.messaging().send(payload, false).then(result => {
console.log("Notification sent!");
});
});
});
When I'm trying to create this function using firebase deploy --only functions, I'm getting an error in console.
/Users/rachitgoyal/functions/index.js
35:40 error Each then() should return a value or throw promise/always-return
✖ 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! /Users/rachitgoyal/.npm/_logs/2019-05-08T08_36_48_838Z-debug.log
Error: functions predeploy error: Command terminated with non-zero exit code1
Additional logs from debug.log for reference:
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node',
1 verbose cli '/usr/local/bin/npm',
1 verbose cli '--prefix',
1 verbose cli '/Users/rachitgoyal/functions',
1 verbose cli 'run',
1 verbose cli 'lint' ]
2 info using npm#6.4.1
3 info using node#v10.15.3
4 verbose run-script [ 'prelint', 'lint', 'postlint' ]
5 info lifecycle functions#~prelint: functions#
6 info lifecycle functions#~lint: functions#
7 verbose lifecycle functions#~lint: unsafe-perm in lifecycle true
8 verbose lifecycle functions#~lint: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/rachitgoyal/functions/node_modules/.bin:/Users/rachitgoyal/.npm-global/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
9 verbose lifecycle functions#~lint: CWD: /Users/rachitgoyal/functions
10 silly lifecycle functions#~lint: Args: [ '-c', 'eslint .' ]
11 silly lifecycle functions#~lint: Returned: code: 1 signal: null
12 info lifecycle functions#~lint: Failed to exec lint script
13 verbose stack Error: functions# lint: `eslint .`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:301:16)
13 verbose stack at EventEmitter.emit (events.js:189:13)
13 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:189:13)
13 verbose stack at maybeClose (internal/child_process.js:970:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
14 verbose pkgid functions#
15 verbose cwd /Users/rachitgoyal
16 verbose Darwin 18.5.0
17 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "--prefix" "/Users/rachitgoyal/functions" "run" "lint"
18 verbose node v10.15.3
19 verbose npm v6.4.1
20 error code ELIFECYCLE
21 error errno 1
22 error functions# lint: `eslint .`
22 error Exit status 1
23 error Failed at the functions# lint script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
The funny thing here is that if I comment the below code in my index.js, the deployment works fine.
const payload = {
notification: {
title: "Added",
body: "Data Added"
}
};
admin.messaging().send(payload, false).then(result => {
console.log("Notification sent!");
});
So I'm assuming I'm doing something wrong with the initialization of the notification. Or I'm not returning the values to Promise properly. Any help here would be greatly appreciated.
Promise.all() and admin.messaging().send() both return a Promise, therefore you need to chain those promises.
However it is not clear why you do
const value = snap.data().original;
console.log('notifying ' + value);
return Promise.all([value])
.then(result => {
const value = result[0].data().value;
...
If you just want to use the value of value in your notification, you don't need to use Promise.all() at all and you should do as follows:
exports.makeUppercase = functions.firestore.document('messages/{messageId}')
.onCreate((snap, context) => {
const value = snap.data().original;
console.log('notifying ' + value);
const payload = {
notification: {
title: "Added",
body: value + "Data Added" //Here we use value
}
};
return admin.messaging().send(payload, false)
.then(result => { //Note that if you don't need the console.log you can get rid of this then()
console.log("Notification sent!");
return null;
});
});

Unable to deploy cloud functions

when I deployed my functions following error came up I tried everything but I cannot solve the problem
I am writing the function for push notification i think i write the code correctly but i am not sure its correct or not
This is the error which I receive on CMD
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\000\AppData\Roaming\npm-cache\_logs\2018-07-
20T15_42_18_516Z-debug.log
Error: functions predeploy error: Command terminated with non-zero exit
code1
This is the LOG File
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-
cli.js',
1 verbose cli '%RESOURCE_DIR%',
1 verbose cli 'run',
1 verbose cli 'lint' ]
2 info using npm#6.1.0
3 info using node#v10.4.1
4 verbose run-script [ 'prelint', 'lint', 'postlint' ]
5 info lifecycle functions#~prelint: functions#
6 info lifecycle functions#~lint: functions#
7 verbose lifecycle functions#~lint: unsafe-perm in lifecycle true
9 verbose lifecycle functions#~lint: CWD: C:\Users\000\fb-
functions\%RESOURCE_DIR%
10 silly lifecycle functions#~lint: Args: [ '/d /s /c', 'eslint .' ]
11 silly lifecycle functions#~lint: Returned: code: 1 signal: null
12 info lifecycle functions#~lint: Failed to exec lint script
13 verbose stack Error: functions# lint: `eslint .`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (C:\Program
Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:304:16)
13 verbose stack at EventEmitter.emit (events.js:182:13)
13 verbose stack at ChildProcess.<anonymous> (C:\Program
Files\nodejs\node_modules\npm\node_modules\npm-
lifecycle\lib\spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:182:13)
13 verbose stack at maybeClose (internal/child_process.js:961:16)
13 verbose stack at Process.ChildProcess._handle.onexit
(internal/child_process.js:248:5)
14 verbose pkgid functions#
15 verbose cwd C:\Users\000\fb-functions
16 verbose Windows_NT 10.0.10586
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program
Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "--prefix"
"%RESOURCE_DIR%" "run" "lint"
18 verbose node v10.4.1
19 verbose npm v6.1.0
20 error code ELIFECYCLE
21 error errno 1
22 error functions# lint: `eslint .`
22 error Exit status 1
23 error Failed at the functions# lint script.
23 error This is probably not a problem with npm. There is likely
additional logging output above.
24 verbose exit [ 1, true ]
This is the code which i wite in index.js
'use strict'
const functions = require('firebase-functions');
const admin = require ('firebase-admin');
admin.initializApp(functions.config().firebase);
exports.sendNotification=
functions.database.ref('/Notifications/${receiver_id}/{notification_id}')
.onWrite(event =>{
const receiver_id = event.params.receiver_id;
const notification_id = event.params.notification_id;
console.log('We have a Notifications to send to :',
receiver_id);
if (!event.data.val())
{
return console.log('A Notifications has been deleted from
the database', notification_id);
}
const deviceToken =
admin.database().ref(`/Users/${receiver_id}/device_token`)
.once('value');
return deviceToken.then(response =>
{
const token_id = result.val();
const payload =
{
notifications;
title: "Friend Request",
body: "You have a New Friend",
icon: "default"
return admin.messaging().sendToDevice(token_id, payload)
.then(response =>{
console.log('This was the notification feature.');
});
};
});
});
What version of Cloud Functions are you using? If you are on 1.0 or later, then there are a couple of things to resolve in the code. For one, the guide indicates that Realtime Database .onWrite triggers pass two parameters: change and context. Also, the path shouldn't have a "$" in it. Also, the parameters object appears to encompassing the second half of all of the code. And in that payload it says "notifications;", but I'm not sure what that's supposed to be. Seems like it should match the payload shown in the guide. There may yet be other errors I didn't catch. If it were me, I'd probably try getting a simpler function to successfully deploy, and then add to it piece by piece.
exports.sendNotification = functions.database.ref('/Notifications/{receiver_id}/{notification_id}')
.onWrite((change, context) => {
const receiver_id = context.params.receiver_id;
const notification_id = context.params.notification_id;
console.log('We have a Notifications to send to :', receiver_id);
if (!change.after.val()) {
return console.log('A Notifications has been deleted from the database', notification_id);
}
const deviceToken = admin.database().ref(`/Users/${receiver_id}/device_token`)
.once('value');
return deviceToken.then(response => {
const token_id = result.val();
const payload = {
notification: {
title: 'Friend Request',
body: 'You have a New Friend',
icon: 'default'
}
};
return admin.messaging().sendToDevice(token_id, payload)
.then(response => {
console.log('This was the notification feature.');
});
});
});

grunt: problems npm with proxy

I am having problems with the proxy but I think it is ok about the configuration. It is when I just executing npm install.
my error in console is:
my file npm-debug.log tells me:
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'install',
1 verbose cli 'grunt-contrib-concat',
1 verbose cli '--dev-save',
1 verbose cli '--global' ]
2 info using npm#2.11.3
3 info using node#v0.12.7
4 verbose install initial load of C:\Users\dmora\AppData\Roaming\npm\package.json
5 verbose readDependencies loading dependencies from C:\Users\dmora\AppData\Roaming\npm\package.json
6 silly cache add args [ 'grunt-contrib-concat', null ]
7 verbose cache add spec grunt-contrib-concat
8 silly cache add parsed spec { raw: 'grunt-contrib-concat',
8 silly cache add scope: null,
8 silly cache add name: 'grunt-contrib-concat',
8 silly cache add rawSpec: '',
8 silly cache add spec: '*',
8 silly cache add type: 'range' }
9 silly addNamed grunt-contrib-concat#*
10 verbose addNamed "*" is a valid semver range for grunt-contrib-concat
11 silly addNameRange { name: 'grunt-contrib-concat', range: '*', hasData: false }
12 silly mapToRegistry name grunt-contrib-concat
13 silly mapToRegistry using default registry
14 silly mapToRegistry registry http://registry.npmjs.org/
15 silly mapToRegistry uri http://registry.npmjs.org/grunt-contrib-concat
16 verbose addNameRange registry:http://registry.npmjs.org/grunt-contrib-concat not in flight; fetching
17 verbose request uri http://registry.npmjs.org/grunt-contrib-concat
18 verbose request no auth needed
19 info attempt registry request try #1 at 17:48:55
20 verbose request id 5852220cb81144b0
21 http request GET http://registry.npmjs.org/grunt-contrib-concat
22 info retry will retry, error on last attempt: Error: connect ECONNREFUSED
23 info attempt registry request try #2 at 17:49:06
24 http request GET http://registry.npmjs.org/grunt-contrib-concat
25 info retry will retry, error on last attempt: Error: connect ECONNREFUSED
26 info attempt registry request try #3 at 17:50:07
27 http request GET http://registry.npmjs.org/grunt-contrib-concat
28 verbose stack Error: connect ECONNREFUSED
28 verbose stack at exports._errnoException (util.js:746:11)
28 verbose stack at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1010:19)
29 verbose cwd D:\_PROYECTOS\Serunet CK.Client\SeruWeb\SN.CK.Front\Serunet.CK.Client.Web.Tests.ShowInBrowse
30 error Windows_NT 6.1.7601
31 error argv "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "grunt-contrib-concat" "--dev-save" "--global"
32 error node v0.12.7
33 error npm v2.11.3
34 error code ECONNREFUSED
35 error errno ECONNREFUSED
36 error syscall connect
37 error Error: connect ECONNREFUSED
37 error at exports._errnoException (util.js:746:11)
37 error at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1010:19)
37 error { [Error: connect ECONNREFUSED]
37 error code: 'ECONNREFUSED',
37 error errno: 'ECONNREFUSED',
37 error syscall: 'connect' }
38 error If you are behind a proxy, please make sure that the
38 error 'proxy' config is set properly. See: 'npm help config'
39 verbose exit [ 1, true ]
Finally I insert my .npmrc file:
proxy=http://Domain\user:password#xx.xx.xx.xx:8080/
https-proxy=http://Domain\user:password#xx.xx.xx.xx:8080/
registry=http://registry.npmjs.org/
strict-ssl = false
ca = null
.npmrc file is in directory: c:\users\myuser\.npmrc
I think everything is correct but it is giving me that errors.
What is wrong in configuration?
It was problem of the proxy of that corporation. Where I am now it is working fine. For me it is resolved.

npm install throws 407 error with HTML

when I run npm install I get a very long error saying error parsing json and continues with the source code of a HTML page that tells me I have a '407 Proxy Authentication Required' error.
The full log can be seen here: http://pastebin.com/T7a4zuYK
this is what npm config list returns:
; cli configs
registry = "http://registry.npmjs.org/"
user-agent = "npm/1.4.28 node/v0.10.34 win32 x64"
; userconfig C:\Users\PV01054\.npmrc
https-proxy = "http://localhost:3128/"
proxy = "http://localhost:3128/"
registry = "http://registry.npmjs.org/"
; builtin config undefined
prefix = "C:\\Users\\PV01054\\AppData\\Roaming\\npm"
; node bin location = C:\Program Files\nodejs\\node.exe
; cwd = C:\Repos\randstad-nl
; HOME = C:\Users\PV01054
; 'npm config ls -l' to show all defaults.

Resources