当我尝试部署Angular函数时,我遇到了一个eslint错误。我已确定该问题包含在本文中的代码段中:https://medium.com/@markgoho/create-a-contact-form-in-angular-using-cloud-functions-for-firebase-5e390bdf5600
以下是我从文章中抓取并放入index.js
文件中的代码段:
exports.sendContactMessage = functions.database.ref('/messages/{pushKey}').onWrite(event => {
const snapshot = event.data;
// Only send email for new messages.
if (snapshot.previous.val() || !snapshot.val().name) {
return;
}
const val = snapshot.val();
const mailOptions = {
to: 'test@example.com',
subject: `Information Request from ${val.name}`,
html: val.html
};
return mailTransport.sendMail(mailOptions).then(() => {
return console.log('Mail sent to: test@example.com')
});
});
这是完整的错误输出:
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/kwlester/Documents/JurassicRevenge/commonwealthlinen/functions',
1 verbose cli 'run',
1 verbose cli 'lint' ]
2 info using npm@4.5.0
3 info using node@v6.10.2
4 verbose run-script [ 'prelint', 'lint', 'postlint' ]
5 info lifecycle functions@~prelint: functions@
6 silly lifecycle functions@~prelint: no script for prelint, continuing
7 info lifecycle functions@~lint: functions@
8 verbose lifecycle functions@~lint: unsafe-perm in lifecycle true
9 verbose lifecycle functions@~lint: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/Users/kwlester/Documents/JurassicRevenge/commonwealthlinen/functions/node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
10 verbose lifecycle functions@~lint: CWD: /Users/kwlester/Documents/JurassicRevenge/commonwealthlinen/functions
11 silly lifecycle functions@~lint: Args: [ '-c', 'eslint .' ]
12 silly lifecycle functions@~lint: Returned: code: 1 signal: null
13 info lifecycle functions@~lint: Failed to exec lint script
14 verbose stack Error: functions@ lint: `eslint .`
14 verbose stack Exit status 1
14 verbose stack at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:279:16)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at EventEmitter.emit (events.js:191:7)
14 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at ChildProcess.emit (events.js:191:7)
14 verbose stack at maybeClose (internal/child_process.js:886:16)
14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
15 verbose pkgid functions@
16 verbose cwd /Users/kwlester/Documents/JurassicRevenge/commonwealthlinen
17 verbose Darwin 17.4.0
18 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "--prefix" "/Users/kwlester/Documents/JurassicRevenge/commonwealthlinen/functions" "run" "lint"
19 verbose node v6.10.2
20 verbose npm v4.5.0
21 error code ELIFECYCLE
22 error errno 1
23 error functions@ lint: `eslint .`
23 error Exit status 1
24 error Failed at the functions@ lint script 'eslint .'.
24 error Make sure you have the latest version of node.js and npm installed.
24 error If you do, this is most likely a problem with the functions package,
24 error not with npm itself.
24 error Tell the author that this fails on your system:
24 error eslint .
24 error You can get information on how to open an issue for this project with:
24 error npm bugs functions
24 error Or if that isn't available, you can get their info via:
24 error npm owner ls functions
24 error There is likely additional logging output above.
25 verbose exit [ 1, true ]
当我删除第三方代码段时,错误就会消失。
我的Javascript知识非常有限,所以我很难找到问题所在。我该如何解决这个问题?
答案 0 :(得分:1)
日志建议您验证是否正在运行最新节点和npm。如果您在Windows上,节点安装也将安装最新的npm。我建议先给它一个。
日志建议:
Make sure you have the latest version of node.js and npm installed.
看起来它提到您使用的是node v6.10.2
,而最新版本是v9.5.0