'Why would a standard top-of-file import to suddenly cause failing on `npm run build` but not on `npm run dev`?
The module in question requires this, which works for dev
import { RRule, RRuleSet, rrulestr } from 'rrule'
This results in the following error from npm run build
import { RRule } from "rrule";
^^^^^
SyntaxError: Named export 'RRule' not found. The requested module 'rrule' 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 'rrule';
const { RRule } = pkg;
Then, when I do the import pkg like it suggested, that works for build but not on dev.
The normal import worked for months. About a month ago it stopped working and required this constant switcharoo between build and dev.
As far as I can tell, there were no updates to the module, os or environment. I'm on WSL2 ubuntu, but I have updates turned off. The package.json has not changed, I verified thru git file history.
So my questions are:
- What could have caused this?
- Neverminding the cause, how could I set this up so that I don't have to keep changing the import statements? Like for example if it sees localhost.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
