-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
Description
Describe the bug
Given an index.mjs file with the following line of code:
console.log(import.meta.resolve("./index.mjs"));It works properly when running node index.mjs, but throws an error when running in vite-node npx vite-node index.mjs: TypeError: __vite_ssr_import_meta__.resolve is not a function
Reproduction
mkdir repro && cd $_echo 'console.log(import.meta.resolve("./index.mjs"));' > index.mjsnode index.mjswill printfile://.../repro/index.mjsnpx vite-node index.mjswill print
Need to install the following packages:
vite-node@2.1.5
Ok to proceed? (y)
/home/gautier/repro/index.mjs:1
'use strict';async (__vite_ssr_import__,__vite_ssr_dynamic_import__,__vite_ssr_exports__,__vite_ssr_exportAll__,__vite_ssr_import_meta__,require,exports,module,__filename,__dirname)=>{{console.log(__vite_ssr_import_meta__.resolve("./index.mjs"));
^
TypeError: __vite_ssr_import_meta__.resolve is not a function
at /home/gautier/repro/index.mjs:1:25
at ViteNodeRunner.runModule (file:///home/gautier/.npm/_npx/f2342a4b64a2bc92/node_modules/vite-node/dist/client.mjs:399:11)
at ViteNodeRunner.directRequest (file:///home/gautier/.npm/_npx/f2342a4b64a2bc92/node_modules/vite-node/dist/client.mjs:381:16)
at ViteNodeRunner.cachedRequest (file:///home/gautier/.npm/_npx/f2342a4b64a2bc92/node_modules/vite-node/dist/client.mjs:206:14)
at ViteNodeRunner.executeFile (file:///home/gautier/.npm/_npx/f2342a4b64a2bc92/node_modules/vite-node/dist/client.mjs:169:12)
at CAC.run (file:///home/gautier/.npm/_npx/f2342a4b64a2bc92/node_modules/vite-node/dist/cli.mjs:99:5)
Node.js v20.18.0
System Info
System:
OS: Linux 5.15 Ubuntu 24.04.1 LTS 24.04.1 LTS (Noble Numbat)
CPU: (16) x64 AMD Ryzen 7 4800HS with Radeon Graphics
Memory: 3.52 GB / 7.47 GB
Container: Yes
Shell: 5.9 - /home/linuxbrew/.linuxbrew/bin/zsh
Binaries:
Node: 20.18.0 - ~/.pkgx/nodejs.org/v20.18.0/bin/node
npm: 10.9.1 - ~/.pkgx/npmjs.com/v10.9.1/bin/npm
vite-node: 2.1.5Used Package Manager
npm
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Reactions are currently unavailable