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

Hardhat & Dotenv: Cannot find module 'tslib' #536

Closed
kalloc opened this issue Dec 17, 2023 · 2 comments
Closed

Hardhat & Dotenv: Cannot find module 'tslib' #536

kalloc opened this issue Dec 17, 2023 · 2 comments

Comments

@kalloc
Copy link

kalloc commented Dec 17, 2023

I'm trying to use LSP with my Neovim setup and I got an error Cannot find module 'tslib' in one of the projects.
After long inspection, I did a small repo that can reproduce the bug.
As I learned, the problem was caused by using the typescript hardhat and including dotenv in hardhat.config.ts.

The repo: https://github.com/kalloc/nomicfoundation-solidity-language-server-dotenv-bug

Full trace:

[coc.nvim] Hardhat project 'bug-tslib-error' was not able to initialize correctly:
 Cannot find module 'tslib'
Require stack:
- /home/y/work/bug-tslib-error/hardhat.config.ts
- /home/y/work/bug-tslib-error/node_modules/.pnpm/hardhat@2.14.1_ts-node@10.9.1_typescript@5.1.6/node_modules/hardhat/internal/core/config/config-loading.js
- /home/y/work/work/bug-tslib-error/node_modules/.pnpm/hardhat@2.14.1_ts-node@10.9.1_typescript@5.1.6/node_modules/hardhat/register.js
- /home/y/.nvm/versions/node/v18.12.1/lib/node_modules/@ignored/solidity-language-server/out/worker/WorkerProcess.js

LSP Trace: https://gist.github.com/kalloc/3f971ac9c0be79c1ae775457d108b6e0

@kalloc
Copy link
Author

kalloc commented Dec 17, 2023

How I use LSP


        "solidity": {
            "command": "nomicfoundation-solidity-language-server",
            "trace.server": "verbose",
            "trace.server.format": "json",
            "args": [
                "--stdio"
            ],
            "filetypes": [
                "solidity"
            ],
            "rootPatterns": [
                "foundry.toml",
                "package.json",
                ".git"
            ],
        }

@kalloc
Copy link
Author

kalloc commented Dec 17, 2023

The solution for me is to install tslib (pnpm add tslib -D), but I think if hardhat (pnpm run compile) works, LSP should work too.

@kanej kanej closed this as completed Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants