我正在尝试将功能部署到Firebase,但是无论何时执行
firebase deploy
我确实得到了错误。
C:\Users\vimiv>firebase deploy
=== Deploying to 'touch-keeper'...
i deploying functions, hosting
Running command: npm --prefix "%RESOURCE_DIR%" run lint
> functions@ lint C:\Users\vimiv\functions
> 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:\Users\vimiv\functions\node_modules\optionator\lib\help.js:6:14)
at Object.<anonymous> (C:\Users\vimiv\functions\node_modules\optionator\lib\help.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:\Users\vimiv\AppData\Roaming\npm-cache\_logs\2018-08-
17T10_47_41_587Z-debug.log
Error: functions predeploy error: Command terminated with non-zero exit code1
这是我的index.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");
});
这是我的package.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前缀命令
答案 0 :(得分:1)
您需要安装您在函数中可能使用的任何依赖项。在函数文件夹中运行npm install
。
答案 1 :(得分:0)
在npm install -g word-wrap
之后尝试firebase deploy
。