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 during "tree-sitter generate" #70

Closed
klimeryk opened this issue Sep 7, 2024 · 5 comments
Closed

Error during "tree-sitter generate" #70

klimeryk opened this issue Sep 7, 2024 · 5 comments

Comments

@klimeryk
Copy link

klimeryk commented Sep 7, 2024

I've been following #19 to set up this project in NeoVim. However, when running :TSInstall blade, I'm getting the following error:

nvim-treesitter[blade]: Error during "tree-sitter generate"                                                                                                                         
file:///Users/klimeryk/.local/share/nvim/tree-sitter-blade/grammar.js:1                                                                                                             
module.exports = grammar({                                                                                                                                                          
^                                                                                                                                                                                   
                                                                                                                                                                                    
ReferenceError: module is not defined in ES module scope                                                                                                                            
This file is being treated as an ES module because it has a '.js' file extension and '/Users/klimeryk/.local/share/nvim/tree-sitter-blade/package.json' contains "type": "module". T
o treat it as a CommonJS script, rename it to use the '.cjs' file extension.                                                                                                        
    at file:///Users/klimeryk/.local/share/nvim/tree-sitter-blade/grammar.js:1:1                                                                                                    
    at ModuleJob.run (node:internal/modules/esm/module_job:234:25)                                                                                                                  
    at async ModuleLoader.import (node:internal/modules/esm/loader:473:24)                                                                                                          
    at async file:///Users/klimeryk/.local/share/nvim/tree-sitter-blade/[eval1]:489:16                                                                                              
                                                                                                                                                                                    
Node.js v20.17.0                                                                                                                                                                    
Failed to load grammar.js                                                                                                                                                           
                                                                                                                                                                                    
Caused by:                                                                                                                                                                          
    node process exited with status 1  

Looking at recent changes, seems that 5eae5e1 might have caused this? Removing type: module from package.json indeed allowed me to install it successfully (https://github.com/klimeryk/tree-sitter-blade/commit/6d0cb7902db63daf694dd2c74a8e1da772114feb). But I'm not sure if that's the ideal fix, depending on if you do want it as ES module or not.

@cdarken
Copy link

cdarken commented Sep 11, 2024

This fix works for me too. Maybe a pull request would be in order.

@EmranMR
Copy link
Owner

EmranMR commented Sep 11, 2024

Hi all, sorry for the delay and the inconvenience this has caused. This was due to the ESLint's recent migration from commonJS to ES module!

Please pull the new commit and it should work fine now :).

@cdarken
Copy link

cdarken commented Sep 11, 2024

@EmranMR have you tried your fix? It won't install. This is the error for me:

nvim-treesitter[blade]: Error during "tree-sitter generate"                                                                     
No such file or directory (os error 2)

@EmranMR EmranMR reopened this Sep 11, 2024
EmranMR added a commit that referenced this issue Sep 11, 2024
@EmranMR
Copy link
Owner

EmranMR commented Sep 11, 2024

@cdarken Mmm you are right, let me give it another shot, the issue is if I remove module from package.json it messes with the CI, and the tree-sitter and its dependencies are all commonJS unfortunately... :/ .
I am just going to remove CI action for now, until I figure this out!

It should work again this time for sure! 😅.

@klimeryk
Copy link
Author

Thanks for the fix - confirmed it's working now again 🙇

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

3 participants