eslint: error Parsing error: The keyword 'const' is reserved











up vote
98
down vote

favorite
9












I am getting this error from ESLint:



error  Parsing error: The keyword 'const' is reserved


from this code:



const express = require('express');
const app = express();
const _ = require('underscore');


I've tried removing node_modules and reinstalling all npm packages (as suggested here), but to no avail.










share|improve this question




























    up vote
    98
    down vote

    favorite
    9












    I am getting this error from ESLint:



    error  Parsing error: The keyword 'const' is reserved


    from this code:



    const express = require('express');
    const app = express();
    const _ = require('underscore');


    I've tried removing node_modules and reinstalling all npm packages (as suggested here), but to no avail.










    share|improve this question


























      up vote
      98
      down vote

      favorite
      9









      up vote
      98
      down vote

      favorite
      9






      9





      I am getting this error from ESLint:



      error  Parsing error: The keyword 'const' is reserved


      from this code:



      const express = require('express');
      const app = express();
      const _ = require('underscore');


      I've tried removing node_modules and reinstalling all npm packages (as suggested here), but to no avail.










      share|improve this question















      I am getting this error from ESLint:



      error  Parsing error: The keyword 'const' is reserved


      from this code:



      const express = require('express');
      const app = express();
      const _ = require('underscore');


      I've tried removing node_modules and reinstalling all npm packages (as suggested here), but to no avail.







      javascript node.js ecmascript-6 eslint






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Oct 14 at 16:26









      MultiplyByZer0

      2,66322138




      2,66322138










      asked Mar 9 '17 at 22:19









      opike

      2,213114277




      2,213114277
























          4 Answers
          4






          active

          oldest

          votes

















          up vote
          147
          down vote



          accepted










          ESLint defaults to ES5 syntax-checking. You'll want to override to the latest well-supported version of JavaScript.



          Try adding a .eslintrc file to your project. Inside it:



          {
          "parserOptions": {
          "ecmaVersion": 2017
          },

          "env": {
          "es6": true
          }
          }


          Hopefully this helps.



          EDIT: I also found this example .eslintrc which might help.






          share|improve this answer























          • so much trouble to find this, thank you
            – Michael Pell
            Jul 26 '17 at 2:06




















          up vote
          2
          down vote













          I used .eslintrc.js and I have added following code.



          module.exports = {
          "parserOptions": {
          "ecmaVersion": 6
          }
          };





          share|improve this answer




























            up vote
            0
            down vote













            I had this same problem with this part of my code:



            const newComment = {
            dishId: dishId,
            rating: rating,
            author: author,
            comment: comment
            };
            newComment.date = new Date().toISOString();


            Same error, const is a reserved word.



            The thing is, I made the .eslintrc.js from the link you gave in the update and still got the same error. Also, I get an parsing error in the .eslintrc.js: Unexpected token ':'.



            Right in this part:



            "env": {
            "browser": true,
            "node": true,
            "es6": true
            },

            ...





            share|improve this answer






























              up vote
              0
              down vote













              you also can add this inline instead of config, just add it to the same file before you add your own disable stuff



              /* eslint-env es6 */
              /* eslint-disable no-console */


              my case was disable a file and eslint-disable were not working for me alone



              /* eslint-env es6 */
              /* eslint-disable */





              share|improve this answer





















                Your Answer






                StackExchange.ifUsing("editor", function () {
                StackExchange.using("externalEditor", function () {
                StackExchange.using("snippets", function () {
                StackExchange.snippets.init();
                });
                });
                }, "code-snippets");

                StackExchange.ready(function() {
                var channelOptions = {
                tags: "".split(" "),
                id: "1"
                };
                initTagRenderer("".split(" "), "".split(" "), channelOptions);

                StackExchange.using("externalEditor", function() {
                // Have to fire editor after snippets, if snippets enabled
                if (StackExchange.settings.snippets.snippetsEnabled) {
                StackExchange.using("snippets", function() {
                createEditor();
                });
                }
                else {
                createEditor();
                }
                });

                function createEditor() {
                StackExchange.prepareEditor({
                heartbeatType: 'answer',
                convertImagesToLinks: true,
                noModals: true,
                showLowRepImageUploadWarning: true,
                reputationToPostImages: 10,
                bindNavPrevention: true,
                postfix: "",
                imageUploader: {
                brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                allowUrls: true
                },
                onDemand: true,
                discardSelector: ".discard-answer"
                ,immediatelyShowMarkdownHelp:true
                });


                }
                });














                 

                draft saved


                draft discarded


















                StackExchange.ready(
                function () {
                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f42706584%2feslint-error-parsing-error-the-keyword-const-is-reserved%23new-answer', 'question_page');
                }
                );

                Post as a guest















                Required, but never shown

























                4 Answers
                4






                active

                oldest

                votes








                4 Answers
                4






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes








                up vote
                147
                down vote



                accepted










                ESLint defaults to ES5 syntax-checking. You'll want to override to the latest well-supported version of JavaScript.



                Try adding a .eslintrc file to your project. Inside it:



                {
                "parserOptions": {
                "ecmaVersion": 2017
                },

                "env": {
                "es6": true
                }
                }


                Hopefully this helps.



                EDIT: I also found this example .eslintrc which might help.






                share|improve this answer























                • so much trouble to find this, thank you
                  – Michael Pell
                  Jul 26 '17 at 2:06

















                up vote
                147
                down vote



                accepted










                ESLint defaults to ES5 syntax-checking. You'll want to override to the latest well-supported version of JavaScript.



                Try adding a .eslintrc file to your project. Inside it:



                {
                "parserOptions": {
                "ecmaVersion": 2017
                },

                "env": {
                "es6": true
                }
                }


                Hopefully this helps.



                EDIT: I also found this example .eslintrc which might help.






                share|improve this answer























                • so much trouble to find this, thank you
                  – Michael Pell
                  Jul 26 '17 at 2:06















                up vote
                147
                down vote



                accepted







                up vote
                147
                down vote



                accepted






                ESLint defaults to ES5 syntax-checking. You'll want to override to the latest well-supported version of JavaScript.



                Try adding a .eslintrc file to your project. Inside it:



                {
                "parserOptions": {
                "ecmaVersion": 2017
                },

                "env": {
                "es6": true
                }
                }


                Hopefully this helps.



                EDIT: I also found this example .eslintrc which might help.






                share|improve this answer














                ESLint defaults to ES5 syntax-checking. You'll want to override to the latest well-supported version of JavaScript.



                Try adding a .eslintrc file to your project. Inside it:



                {
                "parserOptions": {
                "ecmaVersion": 2017
                },

                "env": {
                "es6": true
                }
                }


                Hopefully this helps.



                EDIT: I also found this example .eslintrc which might help.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Oct 14 at 16:22









                MultiplyByZer0

                2,66322138




                2,66322138










                answered Mar 9 '17 at 22:26









                iamjpg

                2,78711114




                2,78711114












                • so much trouble to find this, thank you
                  – Michael Pell
                  Jul 26 '17 at 2:06




















                • so much trouble to find this, thank you
                  – Michael Pell
                  Jul 26 '17 at 2:06


















                so much trouble to find this, thank you
                – Michael Pell
                Jul 26 '17 at 2:06






                so much trouble to find this, thank you
                – Michael Pell
                Jul 26 '17 at 2:06














                up vote
                2
                down vote













                I used .eslintrc.js and I have added following code.



                module.exports = {
                "parserOptions": {
                "ecmaVersion": 6
                }
                };





                share|improve this answer

























                  up vote
                  2
                  down vote













                  I used .eslintrc.js and I have added following code.



                  module.exports = {
                  "parserOptions": {
                  "ecmaVersion": 6
                  }
                  };





                  share|improve this answer























                    up vote
                    2
                    down vote










                    up vote
                    2
                    down vote









                    I used .eslintrc.js and I have added following code.



                    module.exports = {
                    "parserOptions": {
                    "ecmaVersion": 6
                    }
                    };





                    share|improve this answer












                    I used .eslintrc.js and I have added following code.



                    module.exports = {
                    "parserOptions": {
                    "ecmaVersion": 6
                    }
                    };






                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Jun 17 at 9:34









                    Kajornjit Songsaen

                    53638




                    53638






















                        up vote
                        0
                        down vote













                        I had this same problem with this part of my code:



                        const newComment = {
                        dishId: dishId,
                        rating: rating,
                        author: author,
                        comment: comment
                        };
                        newComment.date = new Date().toISOString();


                        Same error, const is a reserved word.



                        The thing is, I made the .eslintrc.js from the link you gave in the update and still got the same error. Also, I get an parsing error in the .eslintrc.js: Unexpected token ':'.



                        Right in this part:



                        "env": {
                        "browser": true,
                        "node": true,
                        "es6": true
                        },

                        ...





                        share|improve this answer



























                          up vote
                          0
                          down vote













                          I had this same problem with this part of my code:



                          const newComment = {
                          dishId: dishId,
                          rating: rating,
                          author: author,
                          comment: comment
                          };
                          newComment.date = new Date().toISOString();


                          Same error, const is a reserved word.



                          The thing is, I made the .eslintrc.js from the link you gave in the update and still got the same error. Also, I get an parsing error in the .eslintrc.js: Unexpected token ':'.



                          Right in this part:



                          "env": {
                          "browser": true,
                          "node": true,
                          "es6": true
                          },

                          ...





                          share|improve this answer

























                            up vote
                            0
                            down vote










                            up vote
                            0
                            down vote









                            I had this same problem with this part of my code:



                            const newComment = {
                            dishId: dishId,
                            rating: rating,
                            author: author,
                            comment: comment
                            };
                            newComment.date = new Date().toISOString();


                            Same error, const is a reserved word.



                            The thing is, I made the .eslintrc.js from the link you gave in the update and still got the same error. Also, I get an parsing error in the .eslintrc.js: Unexpected token ':'.



                            Right in this part:



                            "env": {
                            "browser": true,
                            "node": true,
                            "es6": true
                            },

                            ...





                            share|improve this answer














                            I had this same problem with this part of my code:



                            const newComment = {
                            dishId: dishId,
                            rating: rating,
                            author: author,
                            comment: comment
                            };
                            newComment.date = new Date().toISOString();


                            Same error, const is a reserved word.



                            The thing is, I made the .eslintrc.js from the link you gave in the update and still got the same error. Also, I get an parsing error in the .eslintrc.js: Unexpected token ':'.



                            Right in this part:



                            "env": {
                            "browser": true,
                            "node": true,
                            "es6": true
                            },

                            ...






                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Oct 14 at 0:49









                            DarkSuniuM

                            799819




                            799819










                            answered Oct 14 at 0:10









                            Marcos Sevilla

                            11




                            11






















                                up vote
                                0
                                down vote













                                you also can add this inline instead of config, just add it to the same file before you add your own disable stuff



                                /* eslint-env es6 */
                                /* eslint-disable no-console */


                                my case was disable a file and eslint-disable were not working for me alone



                                /* eslint-env es6 */
                                /* eslint-disable */





                                share|improve this answer

























                                  up vote
                                  0
                                  down vote













                                  you also can add this inline instead of config, just add it to the same file before you add your own disable stuff



                                  /* eslint-env es6 */
                                  /* eslint-disable no-console */


                                  my case was disable a file and eslint-disable were not working for me alone



                                  /* eslint-env es6 */
                                  /* eslint-disable */





                                  share|improve this answer























                                    up vote
                                    0
                                    down vote










                                    up vote
                                    0
                                    down vote









                                    you also can add this inline instead of config, just add it to the same file before you add your own disable stuff



                                    /* eslint-env es6 */
                                    /* eslint-disable no-console */


                                    my case was disable a file and eslint-disable were not working for me alone



                                    /* eslint-env es6 */
                                    /* eslint-disable */





                                    share|improve this answer












                                    you also can add this inline instead of config, just add it to the same file before you add your own disable stuff



                                    /* eslint-env es6 */
                                    /* eslint-disable no-console */


                                    my case was disable a file and eslint-disable were not working for me alone



                                    /* eslint-env es6 */
                                    /* eslint-disable */






                                    share|improve this answer












                                    share|improve this answer



                                    share|improve this answer










                                    answered Nov 21 at 21:32









                                    yousef

                                    39948




                                    39948






























                                         

                                        draft saved


                                        draft discarded



















































                                         


                                        draft saved


                                        draft discarded














                                        StackExchange.ready(
                                        function () {
                                        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f42706584%2feslint-error-parsing-error-the-keyword-const-is-reserved%23new-answer', 'question_page');
                                        }
                                        );

                                        Post as a guest















                                        Required, but never shown





















































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown

































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown







                                        Popular posts from this blog

                                        What visual should I use to simply compare current year value vs last year in Power BI desktop

                                        Alexandru Averescu

                                        Trompette piccolo