Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: "Block-scoped declarations (let, const, function, class) not yet supported outside strict mode" #17

Open
mikelambert opened this issue Jan 2, 2017 · 0 comments

Comments

@mikelambert
Copy link

I am getting the following error when adding this module to my project (tried searching around, but can't find anyone else with this problem on this module):

/myproject/node_modules/babel-plugin-react-autoprefix/index.js:10
  let binding
  ^^^

SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:374:25)
    at Module._extensions..js (module.js:417:10)
    at Object.require.extensions.(anonymous function) [as .js] (/myproject/node_modules/babel-register/lib/node.js:152:7)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Module.require (module.js:354:17)
    at require (internal/module.js:12:17)
    at /myproject/node_modules/babel-core/lib/transformation/file/options/option-manager.js:174:20
    at Array.map (native)

Adding a 'use strict'; to the index.js helps it get a bit further:

/myproject/node_modules/babel-plugin-react-autoprefix/index.js:112
module.exports = ({ types: t }) => ({
                  ^

SyntaxError: Unexpected token {
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:374:25)
    at Module._extensions..js (module.js:417:10)
    at Object.require.extensions.(anonymous function) [as .js] (/myproject/node_modules/babel-register/lib/node.js:152:7)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Module.require (module.js:354:17)
    at require (internal/module.js:12:17)
    at /myproject/node_modules/babel-core/lib/transformation/file/options/option-manager.js:174:20
    at Array.map (native)

Seems like it's using modern features, but the runtime is not expecting them. My .babelrc configuration is as follows:

{
  "presets": ["latest", "react", "stage-0"],
  "plugins": [
    "react-autoprefix",
    "react-hot-loader/babel",
    "transform-object-rest-spread",
    "transform-flow-strip-types",
    ["react-intl", {
        "messagesDir": "../build/messages/",
        "enforceDescriptions": true
    }],
  ],
  "retainLines": true
}
@mikelambert mikelambert changed the title Block-scoped declarations (let, const, function, class) not yet supported outside strict mode Error: "Block-scoped declarations (let, const, function, class) not yet supported outside strict mode" Jan 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant