snowpack: [BUG] Latest release is missing dependencies

Bug Report Quick Checklist

  • I am on the latest version of Snowpack & all plugins.
  • I use Yarn
  • I run Linux
  • I run Snowpack on Node.js v12+

Describe the bug

The very last release seems to have a change that makes it accidentally rely on hoisting. The reported case is node-gyp (which is required in lib/index.js). There may be others, but our tests stop early.

I suspect this file is bundled (are you bundling npm?), with node-gyp being a rare instance of package that cannot be bundled this way. If that’s the case, you may want to add it as a dependency (it’s part of the hot require path, so it’s not optional).

Note that, while clearly exhibited by Yarn, the hoisting problem affects all package managers.

To Reproduce

  1. cd $(mktemp -d) && yarn init -2 && rm -f package.json yarn.lock (I have to simplify that 🙂)
  2. yarn dlx create-snowpack-app my-csa --template @snowpack/app-template-react --use-yarn
  3. cd my-csa && yarn build

Expected behavior

Should work fine.

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 9
  • Comments: 18 (6 by maintainers)

Most upvoted comments

how to resolve this issue in pnpm? I’m getting an error: Package "@npmcli/arborist" not found. Have you installed it?

system details: windows 10 nodejs: v16.2.0 pnpm: 6.10.0 snowpack: v3.8.1

3.7.2

Maybe some higher versions too < 3.8, but I haven’t tested.

Also experiencing this with yarn 2.4.1 and Snowpack 3.3.7. The error message I ran into, for anyone searching for this issue:

Error: snowpack tried to access node-gyp, but it isn’t declared in its dependencies; this makes the require call ambiguous and unsound.

Until this is fixed, you can add this to .yarnrc.yml as a workaround:

packageExtensions:
  "snowpack@*":
    dependencies:
      "node-gyp": "*"

Relevant yarn docs: https://yarnpkg.com/getting-started/migration#a-package-is-trying-to-access-another-package-