gpt4 book ai didi

javascript - 解决 index.js 内的 'eslint' 错误 - Angular 5

转载 作者:行者123 更新时间:2023-12-03 02:33:34 26 4
gpt4 key购买 nike

当我尝试部署 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 ]

当我删除第 3 方代码片段时,错误就会消失。

我的 JavaScript 知识非常有限,所以我很难找到问题所在。我该如何解决这个问题?

最佳答案

日志建议您验证正在运行的最新节点和 npm。如果您使用的是 Windows,则节点安装还将安装最新的 npm。我建议先尝试一下。

日志建议在这里:

Make sure you have the latest version of node.js and npm installed.

看起来它提到您正在使用 node v6.10.2 并且当前最新的是 v9.5.0

关于javascript - 解决 index.js 内的 'eslint' 错误 - Angular 5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48630767/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com