isaacs / rimraf

A `rm -rf` util for nodejs
ISC License
5.62k stars 250 forks source link

Named export 'glob' not found. #294

Closed yanickrochon closed 8 months ago

yanickrochon commented 9 months ago

Using the most recent 5.0.5, I get the following error with Node 20.10.0 :

file:///path/to/project/node_modules/rimraf/dist/esm/index.js:1
import { glob, globSync } from 'glob';
         ^^^^
SyntaxError: Named export 'glob' not found. The requested module 'glob' 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 'glob';
const { glob, globSync } = pkg;

    at ModuleJob._instantiate (node:internal/modules/esm/module_job:132:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:214:5)
    at async ModuleLoader.import (node:internal/modules/esm/loader:329:24)
    at async loadESM (node:internal/process/esm_loader:34:7)
    at async handleMainPromise (node:internal/modules/run_main:113:12)

Node.js v20.10.0
isaacs commented 9 months ago

What does npm ls rimraf glob output?

yanickrochon commented 8 months ago

@isaacs here you go

devDependencies:
glob 10.3.10
rimraf 5.0.5
isaacs commented 8 months ago

No. Please run the actual command and copy and paste the entire output with the tree structure so I can see what got installed where.

npm ls rimraf glob

yanickrochon commented 8 months ago

The project I have is using a Turborepo with pnpm. The output you wanted was giving many different glob versions from various dependencies.

I manually deleted all node_modules in the monorepo and reinstalled everything. It seems to have fixed it.

allprod commented 5 months ago

I'm having the same problem @isaacs . command output:

├─┬ @remix-run/dev@2.8.1
│ ├─┬ @npmcli/package-json@4.0.1
│ │ └── glob@10.3.10 deduped
│ └─┬ cacache@17.1.4
│   └── glob@10.3.10 deduped
├─┬ eslint@8.56.0
│ └─┬ file-entry-cache@6.0.1
│   └─┬ flat-cache@3.2.0
│     └─┬ rimraf@3.0.2
│       └── glob@7.2.3
├── glob@10.3.10
├─┬ remix-development-tools@3.7.1
│ └─┬ beautify@0.0.8
│   └─┬ js-beautify@1.14.11
│     └── glob@10.3.10 deduped
├─┬ tailwindcss@3.4.1
│ └─┬ sucrase@3.35.0
│   └── glob@10.3.10 deduped
├─┬ workbox-build@7.0.0 extraneous
│ └── glob@7.2.3 extraneous
└─┬ workbox-cli@7.0.0 extraneous
  └── glob@7.2.3 extraneous