question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

error 'use strict' is unnecessary inside of modules

See original GitHub issue

I am writing Node.js code and am getting error 'use strict' is unnecessary inside of modules because i use 'use strict'; at the top of all my files. However, if I remove the 'use strict';, then it tells me that I cannot use let or const because they are only available in strict mode. Can you tell me how to solve this?

I am using https://github.com/mastertinner/eslint-config-mastertinner-nodejs for the configuration and eslint 2.1.0.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:2
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

22reactions
nrecommented, Feb 16, 2016

@mastertinner, sourceType: "module" is only for ES6 modules (export, etc). Your modules are Node.js modules (module.exports, etc). You should keep the strict-mode directives in your modules, and remove sourceType: "module" from your config.

(I made a similar mistake in #4832).

0reactions
cloudlenacommented, Feb 16, 2016

Thanks so much, @nre! That solved it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript: use strict is unnecessary inside of modules
Remove 'use strict' . As the error mentions, it's unnecessary. Modules are expected to execute in strict mode. Compilers will add it for...
Read more >
eslint/eslint - Gitter
i'm getting 'use strict' is unnecessary inside of modules when adding 'use ... Something is enabling sourceType: module (or, if you are using...
Read more >
The modern mode, "use strict"
Worth noting that 'use strict' is unnecessary when using ES6 modules ('import' syntax). Its strict out of the box. TWG • 2 years...
Read more >
Deep dive into 'use strict' in JavaScript | Maisie Johnson's blog
ES6 modules​​ It turns out that strict mode is always enabled for modules. I wasn't aware of this behavior. Since modules are a...
Read more >
strict - ESLint - Pluggable JavaScript Linter
In ECMAScript modules, which always have strict mode semantics, the directives are unnecessary. Rule Details. This rule requires or disallows strict mode ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found