错误:函数预部署错误:命令以非零退出码1终止(尝试所有解决方案后)

时间:2019-03-25 09:44:24

标签: android json

我尝试了其他答案的所有可能解决方案,但仍然给我错误。我尝试将\“ $ RESOURCE_DIR \更改为\”%RESOURCE_DIR%\,但是错误仍然存​​在。谁能帮忙。

这是我的index.js文件

const functions = require('firebase-functions');

const request = require('request-promise')

exports.indexPostsToElastic = functions.database.ref('/posts/{post_id}')
.onWrite(( change,context) => {
let postData = change.after.val();
let post_id = context.params.post_id;

console.log('Indexing post:', postData);

let elasticSearchConfig = functions.config().elasticsearch; 
let elasticSearchUrl = elasticSearchConfig.url + 'posts/post/' + post_id;
let elasticSearchMethod = postData ? 'POST' : 'DELETE';

let elasticSearchRequest = {
    method: elasticSearchMethod,
    url: elasticSearchUrl,
    auth:{
        username: elasticSearchConfig.username,
        password: elasticSearchConfig.password,
    },
    body: postData,
    json: true
  };

  return request(elasticSearchRequest).then(response => {
     console.log("ElasticSearch response", response);
  });
  });

这是我的firebase.json文件

{
"functions": {
"predeploy": [
"npm --prefix \"%RESOURCE_DIR%\" run lint"
],
"source": "functions"
}
}

0 个答案:

没有答案