question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Creating an empty `snowpack.config.js` causes other snowpack commands to expect a missing module

See original GitHub issue

Bug Report Quick Checklist

  • I am on the latest version of Snowpack (3.5.6) & all plugins.
  • I use package manager npm v6.14.13
  • I run Snowpack on OSX 10.13.6
  • I run Snowpack on Node.js v14.7.0

Describe the bug

snowpack dev works perfectly for me locally. with no snowpack.config.js. I have installed @snowpack/plugin-webpack ^2.3.1 and am now trying to build/bundle my project.

  • Whenever I create an empty snowpack.config.js (invoked via snowpack init), snowpack dev breaks with a ReferenceError to a missing module it expects.
  • snowpack build also breaks in the same way.
  • If I delete snowpack.config.js and change nothing else, snowpack dev works perfectly again.
  • snowpack build also works without a snowpack.config.js, the downside being that I can’t configure the build.

The same error trace is invariant to re-evaluating my shell, restarting terminal, restarting my computer, or nuking my node modules and trying again.

> snowpack dev

(node:20522) UnhandledPromiseRejectionWarning: ReferenceError: module is not defined
    at file:///<my_repo_dir>/snowpack.config.js:5:1
    at ModuleJob.run (internal/modules/esm/module_job.js:152:23)
    at async Loader.import (internal/modules/esm/loader.js:177:24)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:20522) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:20522) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

To Reproduce

Set up node env with npm init --yes in my project folder, set up project dependencies.

The only non-snowpack dependency in my project is p5 ^1.3.1. I have tried to make snowpack work both with my code set up to expect P5 as an old-school import (<script src="..."></script> to a local file) or with ES6 imports (import p5 from 'p5';), and it doesn’t seem to make a difference either way.

I followed the setup instructions at Snowpack.dev Quick Start.

  1. npm install --save-dev snowpack
  2. Aliased the snowpack runner commands:
// within package.json
"scripts": {
    "start": "snowpack dev",
    "init": "snowpack init",
    "build": "snowpack build"
}
  1. Check that dev server works. npm run start

I then followed the setup instructions at Snowpack.dev Build Pipeline.

  1. npm install --save-dev @snowpack/plugin-webpack
  2. Added plugin information to package.json.
// within package.json
{
  "plugins": [["@snowpack/plugin-webpack"]]
}
  1. Check that npm run start and npm run build work.
  2. npm run init to create a snowpack config file.
  3. Received the error shown in the previous section.

Expected behavior

I expected snowpack to continue working as before upon creation of an empty config file.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:2
  • Comments:6

github_iconTop GitHub Comments

1reaction
dhrubeshcommented, Jul 19, 2021

Hi @1bsilver are you still working on this? I would like to jump in if you’ve not gotten the chance to pick it up yet?

0reactions
1bsilvercommented, Jul 19, 2021

Okay @dhrubesh. Go ahead.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[BUG] Creating an empty `snowpack.config.js` causes other ... - Rysolv
Whenever I create an empty snowpack.config.js (invoked via snowpack init ), snowpack dev breaks with a ReferenceError to a missing module it expects....
Read more >
[BUG] Snowpack --config command is broken - cannot find ...
I am on the latest version of Snowpack & all plugins. · I use package manager yarn (Fill in: npm, yarn, pnpm, etc)....
Read more >
snowpack.config.js
To generate a basic configuration file scaffold in your Snowpack project run snowpack init . mode. Type: "test" | "development" | "production" Default:...
Read more >
Parcel.js
The zero configuration build tool for the web.
Read more >
RequireJS API
requirejs.config({ //By default load any module IDs from js/lib baseUrl: ... means other modules you define via define() may not get executed, so...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found