tapjs/tsimp

`SyntaxError: Named export 'rimraf' not found.`

Closed this issue · 0 comments

So I'm getting this error when running tsimp.

yarn run v1.22.19
$ /Users/gustavopch/Projects/test-tsimp/node_modules/.bin/tsimp scripts/tmp.tsx
(node:81699) ExperimentalWarning: Custom ESM Loaders is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
file:///Users/gustavopch/Projects/test-tsimp/node_modules/sock-daemon/dist/esm/starting-lock.js:7
import { rimraf } from 'rimraf';
         ^^^^^^
SyntaxError: Named export 'rimraf' not found. The requested module 'rimraf' 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 'rimraf';
const { rimraf } = 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:530:24)
    at async initializeLoader (node:internal/process/esm_loader:75:28)
    at async loadESM (node:internal/process/esm_loader:90:5)
    at async handleMainPromise (node:internal/modules/run_main:65:12)

Node.js v18.12.0
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

It happens because node_modules/rimraf in my project refers to rimraf@3 instead of the expected rimraf@5 (which uses a named export). If I explicitly add rimraf@5 to my package.json, it works.