简体   繁体   中英

Missing “use strict” even though it's already declared at top of file

Am getting this Missing "use strict" statement even though it's decalred at the top of the file, which confuses me. This error appears twice, for lines 10 and 12.

'user strict';
var elasticsearch = require('elasticsearch');
var client = new elasticsearch.Client({
  host : 'http://localhost:9200'
});
client.search({
  index: 'twitter',
  type: 'tweets'
}).then(function (resp) {
  var hits = resp.hits.hits;
}, function (err) {
  console.trace(err.message);
});

The code above is largely copy and paste from http://www.fullscale.co/elasticjs/

It appears you've made a typo.

It should be

'use strict';

If you want to read more about 'use strict', how to use it and what it actually does, you can view the following page:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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