I created some firebase functions to send notification when there will be a data change in firestore. It was working fine on my last computer and sending notifications properly in each update.
But issue started when I changed my computer and trying to copy paste the same folder in which index.js, package.json etc are there from my old computer to new one.
Now when I am trying to use commands by specifying the folder path in command prompt, its throwing some errors which I am trying to fix from last 5 days but able to do. I am little new in firebase functions and its commands.
I am pasting all my things below except index.js as it has only one function which was working in last computer. If required I will paste that one also here.
Below is my functions folder.
.eslintrc:
module.exports = {
root: true,
env: {
es6: true,
node: true,
},
extends: [
"eslint:recommended",
"google",
],
rules: {
quotes: ["error", "double"],
},
};
package.json
{
"name": "functions",
"description": "Cloud Functions for Firebase",
"scripts": {
"lint": "eslint .",
"serve": "firebase emulators:start --only functions",
"shell": "firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"engines": {
"node": "14"
},
"main": "index.js",
"dependencies": {
"firebase-admin": "^9.8.0",
"firebase-functions": "^3.14.1"
},
"devDependencies": {
"eslint": "^7.6.0",
"eslint-config-google": "^0.14.0",
"firebase-functions-test": "^0.2.0"
},
"private": true
}
npm Error log:
0 info it worked if it ends with ok
1 verbose cli [
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 '--prefix',
1 verbose cli 'D:\\AmaKala_Project\\functions',
1 verbose cli 'run',
1 verbose cli 'lint'
1 verbose cli ]
2 info using npm@6.14.15
3 info using node@v14.18.0
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: C:\Program
Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-
bin;D:\AmaKala_Project\functions\node_modules\.bin;C:\Program Files
(x86)\Common Files\Oracle\Java\javapath;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\Syst
em32\WindowsPowerShell\v1.0\;C:\windows\System32\OpenSSH\;C:\Program
Files\Git\cmd;C:\ProgramFiles\nodejs\;C:\Users\Ranjit\AppData\Local\Microsoft\WindowsApps;C:\Users\
Ranjit\AppData\Roaming\
npm
9 verbose lifecycle functions@~lint: CWD: D:\AmaKala_Project\functions
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:332:16)
13 verbose stack at EventEmitter.emit (events.js:400:28)
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:400:28)
13 verbose stack at maybeClose (internal/child_process.js:1058:16)
13 verbose stack at Process.ChildProcess._handle.onexit
(internal/child_process.js:293:5)
14 verbose pkgid functions@
15 verbose cwd D:\AmaKala_Project
16 verbose Windows_NT 10.0.19042
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program
Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "--prefix"
"D:\\AmaKala_Project\\functions"
"run" "lint"
18 verbose node v14.18.0
19 verbose npm v6.14.15
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 ]
cmd errors:
Please let me know if any file is required to be paste. Thanks a lot
firebase.json
{
"functions": {
"source": "functions",
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint"
]
}
}
CodePudding user response:
Do one thing remove the node_modules and do npm install first
Edit :
You may also use this link for reference: https://github.com/firebase/firebase-tools/issues/822#issuecomment-406754186