Skip to content
This repository has been archived by the owner on Nov 16, 2020. It is now read-only.

SyntaxError: Unexpected reserved word #20

Closed
chechir opened this issue Oct 26, 2020 · 5 comments
Closed

SyntaxError: Unexpected reserved word #20

chechir opened this issue Oct 26, 2020 · 5 comments

Comments

@chechir
Copy link

chechir commented Oct 26, 2020

Hi, I started getting this error with the new version (I think since 2.1). I'm using Ubuntu

**> pre-commit run -a** 

Trim Trailing Whitespace.................................................Passed                                                                                                                                                      
Fix End of Files.........................................................Passed                                                                                                                                                      
Check for added large files..............................................Passed                                                                                                                                                      
Check Yaml...............................................................Passed                                                                                                                                                      
black....................................................................Passed                                                                                                                                                      
isort....................................................................Passed                                                                                                                                                      
flake8...................................................................Passed                                                                                                                                                      
prettier.................................................................Failed                                                                                                                                                      
- hook id: prettier                                                                                                                                                                                                                  
- exit code: 1                                                                                                                                                                                                                       
                                                                                                                                                                                                                                     
/home/matias.thayer/.cache/pre-commit/repotvnwyngx/node_env-system/lib/node_modules/prettier/third-party.js:9871                                                                                                                     
      for await (const place of this.config.searchPlaces) {                                                                                                                                                                          
          ^^^^^                                                                                                                                                                                                                      
                                                                                                                                                                                                                                     
SyntaxError: Unexpected reserved word                                                                                                                                                                                                
    at createScript (vm.js:80:10)                                                                                                                                                                                                    
    at Object.runInThisContext (vm.js:139:10)                                                                                                                                                                                        
    at Module._compile (module.js:616:28)                                                                                                                                                                                            
    at Object.Module._extensions..js (module.js:663:10)                                                                                                                                                                              
    at Module.load (module.js:565:32)                                                                                                                                                                                                
    at tryModuleLoad (module.js:505:12)                                                                                                                                                                                              
    at Function.Module._load (module.js:497:3)                                                                                                                                                                                       
    at Module.require (module.js:596:17)                                                                                                                                                                                             
    at require (internal/module.js:11:18)                                                                                                                                                                                            
    at Object.<anonymous> (/home/matias.thayer/.cache/pre-commit/repotvnwyngx/node_env-system/lib/node_modules/prettier/index.js:16551:18)                                                                                           
/home/matias.thayer/.cache/pre-commit/repotvnwyngx/node_env-system/lib/node_modules/prettier/third-party.js:9871                                                                                                                     
      for await (const place of this.config.searchPlaces) {                                                                                                                                                                          
          ^^^^^                                                                                                                                                                                                                      
                                                                                                                                                                                                                                     
SyntaxError: Unexpected reserved word                                                                                                                                                                                                
    at createScript (vm.js:80:10)                                                                                                                                                                                                    
    at Object.runInThisContext (vm.js:139:10)                                                                                                                                                                                        
    at Module._compile (module.js:616:28)                                                                                                                                                                                            
    at Object.Module._extensions..js (module.js:663:10)                                                                                                                                                                              
    at Module.load (module.js:565:32)                                                                                                                                                                                                
    at tryModuleLoad (module.js:505:12)                                                                                                                                                                                              
    at Function.Module._load (module.js:497:3)                                                                                                                                                                                       
    at Module.require (module.js:596:17)                                                                                                                                                                                             
    at require (internal/module.js:11:18)                                                                                                                                                                                            
    at Object.<anonymous> (/home/matias.thayer/.cache/pre-commit/repotvnwyngx/node_env-system/lib/node_modules/prettier/index.js:16551:18)                                                                                           
/home/matias.thayer/.cache/pre-commit/repotvnwyngx/node_env-system/lib/node_modules/prettier/third-party.js:9871                                                                                                                     
      for await (const place of this.config.searchPlaces) {                                                                                                                                                                          
          ^^^^^                    

And there are more blocks of errors about " Unexpected reserved word"

Any idea why?
Thanks

@chechir chechir changed the title Prettier@{{version}} is missing SyntaxError: Unexpected reserved word Oct 26, 2020
@fisker
Copy link
Member

fisker commented Oct 26, 2020

I can't reproduce this, can you try to upgrade you Node.js?

@chechir
Copy link
Author

chechir commented Oct 27, 2020

Done, I'm in v13.14.0 now but still the same error.

@HaGuesto
Copy link

HaGuesto commented Nov 5, 2020

I have exactly the same error:

prettier.................................................................Failed
- hook id: prettier
- exit code: 1

/home/hans/.cache/pre-commit/repon3x536y2/node_env-system/lib/node_modules/prettier/third-party.js:9871
      for await (const place of this.config.searchPlaces) {
          ^^^^^

SyntaxError: Unexpected reserved word
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:617:28)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/home/hans/.cache/pre-commit/repon3x536y2/node_env-system/lib/node_modules/prettier/index.js:16561:18)

Here, my pre-commit-config.yaml for prettier

- repo: https://github.com/prettier/pre-commit
  rev: main
  hooks:
  - id: prettier
    files: \.js?$
    types: [file]

It's my first time trying out prettier with pre-commit.

@HaGuesto
Copy link

HaGuesto commented Nov 5, 2020

I had a similar problem with ESLint.
Defining the node version for node env helped me.

@chechir
Copy link
Author

chechir commented Nov 5, 2020

Thanks! that solved it.

adding this to pre-commit-config.yml

default_language_version:
  node: 15.1.0

@chechir chechir closed this as completed Nov 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants