lint-staged / lint-staged

🚫💩 — Run linters on git staged files
https://www.npmjs.com/package/lint-staged
MIT License
13.05k stars 412 forks source link

SyntaxError: Named export 'getStreamAsBuffer' not found #1406

Closed consdu closed 2 months ago

consdu commented 2 months ago

Description

Trying to run last version of lint-staged and I'm getting this error :

import getStream, {getStreamAsBuffer} from 'get-stream';
                   ^^^^^^^^^^^^^^^^^
SyntaxError: Named export 'getStreamAsBuffer' not found. The requested module 'get-stream' 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 'get-stream';
const {getStreamAsBuffer} = pkg;

    at ModuleJob._instantiate (node:internal/modules/esm/module_job:124:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:190:5)

Node.js v18.18.0
husky - pre-commit hook exited with code 1 (error)

Steps

  1. Install last version in already existing project with Next.js 14 / Webpack
  2. Add Husky pre commit hook
  3. Try to commit and getting the error, so basically it doesn't even run

Environment

iiroj commented 2 months ago

Hello, this is not something used directly in lint-staged so it might a problem with your node_modules/. I would try installing again:

rm -rf package-lock.json node_modules
npm install
consdu commented 2 months ago

Ok, thanks a lot for the answer!