繁体   English   中英

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

[英]Resolve 'eslint' error inside index.js - Angular 5

尝试部署Angular函数时出现错误提示。 我已确定该问题包含在本文中找到的代码段中: 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 ]

当我删除第三方代码段时,错误消失了。

我的Java语言知识非常有限,因此我很难找到问题所在。 我该如何解决?

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

日志建议在这里:

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

看起来它提到您正在使用node v6.10.2 ,而最新版本是v9.5.0

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM