You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import vscodeUri from 'vscode-uri';
const { URI } = vscodeUri;
console.log(URI);
worksWithJiti.js:
import { URI } from 'vscode-uri';
console.log(URI);
Describe the bug
I can't find a way for the vscode-uri module to be loadable by both NodeJS and Jiti, I think that the fact it cannot load the module in the worksWithNode.js file is probably a bug.
Additional context
Even if it is not a bug, this behavior prevents me from using vite-plugin-checker in Nuxt 3 since it depends on vscode-uri and loads it like I did in the worksWithNode.js file. Nuxt will try to load it both with NodeJS and Jiti, thus giving me an error whatever I do when I try fixing the plugin.
I'm not the only one with this error, an issue has been opened on the vite-plugin-checker repository, but I see nothing wrong with what they are doing and the issue only happens when using Jiti, which makes me think the issue comes from your side.
For now, my workaround is to patch the plugin to load vscode-uri using the _require made with createRequire but I don't think this is really legit.
Logs
$ node worksWithJiti.js
file:///reproduction/worksWithJiti.js:1
import { URI } from 'vscode-uri';
^^^
SyntaxError: Named export'URI' not found. The requested module 'vscode-uri' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:
import pkg from 'vscode-uri';
const { URI } = pkg;
at ModuleJob._instantiate (node:internal/modules/esm/module_job:123:21)
at async ModuleJob.run (node:internal/modules/esm/module_job:189:5)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:528:24)
at async loadESM (node:internal/process/esm_loader:91:5)
at async handleMainPromise (node:internal/modules/run_main:65:12)
Node.js v18.8.0
$ node worksWithNode.js
[Function: t] {
isUri: [Function (anonymous)],
parse: [Function (anonymous)],
file: [Function (anonymous)],
from: [Function (anonymous)],
revive: [Function (anonymous)]
}
$ node_modules/.bin/jiti worksWithJiti.js
[Function: t] {
isUri: [Function (anonymous)],
parse: [Function (anonymous)],
file: [Function (anonymous)],
from: [Function (anonymous)],
revive: [Function (anonymous)]
}
$ node_modules/.bin/jiti worksWithNode.js
reproduction/node_modules/jiti/lib/index.js:2
throw err /* ↓ Check stack trace ↓ */
^
TypeError: Cannot destructure property 'URI' of '_vscodeUri.default' as it is undefined.
at /reproduction/worksWithNode.js:2:9
at jiti (/reproduction/node_modules/jiti/dist/jiti.js:1:247502)
at Object.<anonymous> (/reproduction/node_modules/jiti/bin/jiti.js:16:1)
at Module._compile (node:internal/modules/cjs/loader:1119:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1173:10)
at Module.load (node:internal/modules/cjs/loader:997:32)
at Module._load (node:internal/modules/cjs/loader:838:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:18:47
Node.js v18.8.0
$
The text was updated successfully, but these errors were encountered:
Environment
Reproduction
package.json:
worksWithNode.js:
worksWithJiti.js:
Describe the bug
I can't find a way for the
vscode-uri
module to be loadable by both NodeJS and Jiti, I think that the fact it cannot load the module in theworksWithNode.js
file is probably a bug.Additional context
Even if it is not a bug, this behavior prevents me from using
vite-plugin-checker
in Nuxt 3 since it depends onvscode-uri
and loads it like I did in theworksWithNode.js
file. Nuxt will try to load it both with NodeJS and Jiti, thus giving me an error whatever I do when I try fixing the plugin.I'm not the only one with this error, an issue has been opened on the vite-plugin-checker repository, but I see nothing wrong with what they are doing and the issue only happens when using Jiti, which makes me think the issue comes from your side.
For now, my workaround is to patch the plugin to load
vscode-uri
using the_require
made withcreateRequire
but I don't think this is really legit.Logs
The text was updated successfully, but these errors were encountered: