https://github.com/tmpfs/spack-optional-dependency-mvp
Spack bundler error with commonjs optional dependency (Linux)
https://github.com/tmpfs/spack-optional-dependency-mvp
Last synced: 1 day ago
JSON representation
Spack bundler error with commonjs optional dependency (Linux)
- Host: GitHub
- URL: https://github.com/tmpfs/spack-optional-dependency-mvp
- Owner: tmpfs
- Created: 2021-07-02T01:43:01.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-07-02T01:43:20.000Z (almost 4 years ago)
- Last Synced: 2025-01-05T02:12:15.473Z (6 months ago)
- Language: JavaScript
- Size: 6.84 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# CommonJS Optional Dependency
This repository reproduces an issue with attempting to dynamically `require()` an optional dependency that cannot be installed on Linux.
To test this you must be running a Linux distro so that the `fsevents` module fails to install.
Then run `npx spack` and `spack` yields this error:
```
(node:13558) UnhandledPromiseRejectionWarning: Error: load_transformed failedCaused by:
0: failed to analyze module
1: failed to resolve fsevents from node_modules/chokidar/lib/fsevents-handler.js
2: not found
(Use `node --trace-warnings ...` to show where the warning was created)
(node:13558) 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: 1)
(node:13558) [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.
```---
The [code that generates this problem](https://github.com/paulmillr/chokidar/blob/master/lib/fsevents-handler.js#L7-L12) is:
```javascript
let fsevents;
try {
fsevents = require('fsevents');
} catch (error) {
if (process.env.CHOKIDAR_PRINT_FSEVENTS_REQUIRE_ERROR) console.error(error);
}
```