我正在尝试将我的函数部署到Firebase,但是当我执行时
firebase deploy
我确实收到错误。
C:Usersvimiv>firebase deploy
=== Deploying to 'touch-keeper'...
i deploying functions, hosting
Running command: npm --prefix "%RESOURCE_DIR%" run lint
> functions@ lint C:Usersvimivfunctions
> eslint .
module.js:549
throw err;
^
Error: Cannot find module 'wordwrap'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (C:Usersvimivfunctionsnode_modulesoptionatorlibhelp.js:6:14)
at Object.<anonymous> (C:Usersvimivfunctionsnode_modulesoptionatorlibhelp.js:247:4)
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)
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:UsersvimivAppDataRoamingnpm-cache_logs2018-08-
17T10_47_41_587Z-debug.log
Error: functions predeploy error: Command terminated with non-zero exit code1
这是我的索引.js
'use-strict'
const admin = require('firebase-admin');
const functions = require('firebase-functions');
admin.initializeApp(functions.config().firebase);
exports.sendMessageNotification = functions.database.ref('DR/MELTING/{itemname}').onWrite(event => {
//const itemname = event.params.itemname;
console.log("Notificatiion Triggered Successfuly");
});
这是我的包.json
{
"name": "functions",
"description": "Cloud Functions for Firebase",
"scripts": {
"lint": "eslint .",
"serve": "firebase serve --only functions",
"shell": "firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"dependencies": {
"firebase-admin": "^6.0.0",
"firebase-functions": "^2.0.5",
"prelude-ls": "^1.1.2",
"word-wrap": "^1.2.3"
},
"devDependencies": {
"eslint": "^4.12.0",
"eslint-plugin-promise": "^3.6.0"
},
"private": true
}
而且我还更改了我的 firebase.json 前缀命令
您需要安装可能在函数中使用的任何依赖项。在函数文件夹中运行npm install
。
尝试使用npm install -g word-wrap
并在firebase deploy
之后