ahmadnassri / node-glob-promise

Promise version of glob

Home Page:https://www.npmjs.com/package/glob-promise

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

If parent project has been installed glob v10, throw error.

mecaota opened this issue · comments

Detail

When I add glob v10.x.x to the parent project as a dependency, node-glob-promise, a grandchild project used through the child project's storybook, hangs with the following error.

ERR! TypeError: glob is not a function
ERR!     at /path/to/project/node_modules/glob-promise/lib/index.js:5:5
ERR!     at new Promise (<anonymous>)
ERR!     at promise (/path/to/project/node_modules/glob-promise/lib/index.js:4:10)
ERR!     at validateConfigurationFiles (/path/to/project/node_modules/@storybook/core-common/dist/index.js:6:1024)
ERR!     at loadMainConfig (/path/to/project/node_modules/@storybook/core-common/dist/index.js:19:6605)
ERR!     at buildStaticStandalone (/path/to/project/node_modules/@storybook/core-server/dist/index.js:25:904)
ERR!     at async withTelemetry (/path/to/project/node_modules/@storybook/core-server/dist/index.js:35:3620)
ERR!     at async build (/path/to/project/node_modules/@storybook/cli/dist/generate.js:430:1058)
ERR!     at async Command.<anonymous> (/path/to/project/node_modules/@storybook/cli/dist/generate.js:433:125)
ERR!  TypeError: glob is not a function
ERR!     at /path/to/project/node_modules/glob-promise/lib/index.js:5:5
ERR!     at new Promise (<anonymous>)
ERR!     at promise (/path/to/project/node_modules/glob-promise/lib/index.js:4:10)
ERR!     at validateConfigurationFiles (/path/to/project/node_modules/@storybook/core-common/dist/index.js:6:1024)
ERR!     at loadMainConfig (/path/to/project/node_modules/@storybook/core-common/dist/index.js:19:6605)
ERR!     at buildStaticStandalone (/path/to/project/node_modules/@storybook/core-server/dist/index.js:25:904)
ERR!     at async withTelemetry (/path/to/project/node_modules/@storybook/core-server/dist/index.js:35:3620)
ERR!     at async build (/path/to/project/node_modules/@storybook/cli/dist/generate.js:430:1058)
ERR!     at async Command.<anonymous> (/path/to/project/node_modules/@storybook/cli/dist/generate.js:433:125)
/path/to/project/node_modules/glob-promise/lib/index.js:5
    glob(pattern, options, (err, files) => err === null ? resolve(files) : reject(err))
    ^

TypeError: glob is not a function
    at /path/to/project/node_modules/glob-promise/lib/index.js:5:5
    at new Promise (<anonymous>)
    at promise (/path/to/project/node_modules/glob-promise/lib/index.js:4:10)
    at validateConfigurationFiles (/path/to/project/node_modules/@storybook/core-common/dist/index.js:6:1024)
    at loadCustomPresets (/path/to/project/node_modules/@storybook/core-common/dist/index.js:12:48)
    at loadAllPresets (/path/to/project/node_modules/@storybook/core-common/dist/index.js:15:1681)
    at getErrorLevel (/path/to/project/node_modules/@storybook/core-server/dist/index.js:35:2072)
    at sendTelemetryError (/path/to/project/node_modules/@storybook/core-server/dist/index.js:35:2793)
    at withTelemetry (/path/to/project/node_modules/@storybook/core-server/dist/index.js:35:3802)
    at async build (/path/to/project/node_modules/@storybook/cli/dist/generate.js:430:1058)

Cause

My project uses storybook, which has a dependency on node-glob-promise, but not on glob.

Apart from that, my project also has glob as a devDependency.

Currently, glob is required as peerDependencies, so the dependency of the parent project will be adopted. As a result, if the parent project is versioned to glob v10, the breaking change in glob v10 will hang an unrelated node-glob-promise, which in turn hangs the storybook.

Shouldn't glob be registered in dependencies instead of peerDependencies?

Also, unrelated to this, I think you can consider supporting v10 to increase the version of glob. The reason why glob v10 hangs is because glob has abolished the default export. https://github.com/isaacs/node-glob/blob/main/changelog.md#1000

The cause of this problem is

node-glob-promise

  • No support for breaking changes in glob v10

storybook

  • No explicit dependency on glob

I believe there is a problem with both of the above.
Here are the solutions I can think of

  1. Move glob from peerDependency to dependency
  2. Modify glob v10 interface

I think you should do 1st, omit glob install from the installation procedure, and update to the final version of 8 or 9 with no interface changes.

Sorry, I wasn't sure enough. Since the dependency on node-glob-promise will be abolished in the next release of Storybook, the above problem is expected to be resolved, so we will close it.

fixed commit

storybookjs/storybook@ac16a38

will take a look at this today, thanks

I am facing a variant of this issue with Maizzle. Because neither glob-promise nor @maizzle/framework specify a version of glob, I have to downgrade my Yarn monorepo's version of glob to ^8 to be able to work with Maizzle.