I was looking into a Discord bug I found and funnily enough it also breaks the copilot LSP 😂.
[START][2024-08-03 11:32:06] LSP logging initiated
[ERROR][2024-08-03 11:32:06] .../vim/lsp/rpc.lua:770 "rpc" "node" "stderr" "file:///Users/hacksore/.local/share/nvim/lazy/copilot.lua/copilot/index.js:3
global.__rootDirectory = __dirname + '/dist/';
^
ReferenceError: __dirname 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/hacksore/package.json' contains \"type\": \"module\". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
at file:///Users/hacksore/.local/share/nvim/lazy/copilot.lua/copilot/index.js:3:26
at ModuleJob.run (node:internal/modules/esm/module_job:222:25)
at async ModuleLoader.import (node:internal/modules/esm/loader:323:24)
at async loadESM (node:internal/process/esm_loader:28:7)
at async handleMainPromise (node:internal/modules/run_main:113:12)
Node.js v20.12.2
Not sure this is fixable but raising the issue for awareness just in case others run into this.
tl;dr don't have a package.json in your homedir with "type": "module" 💀.
I was looking into a Discord bug I found and funnily enough it also breaks the copilot LSP 😂.
Not sure this is fixable but raising the issue for awareness just in case others run into this.
tl;dr don't have a
package.jsonin your homedir with"type": "module"💀.