keystonejs / keystonejs/keystone

Unable to import native module

Open
#7,291 4 comments 3 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
10k
Forks
1.3k
Avg merge
19h 14m
Merged PRs (30d)
19

Description

## How to reproduce

Attempt to import a module that will load a `.node` native module.

## Expected behavior

The app builds and runs normally.

## Actual behavior

Webpack complains there is no loader for the `.node` module:

```
yarn run v1.22.15
$ keystone dev
✨ Starting Keystone
⭐️ Dev Server Starting on http://localhost:3000
⭐️ GraphQL API Starting on http://localhost:3000/api/graphql
✨ Generating GraphQL and Prisma schemas
✨ The database is already in sync with the Prisma schema.
✨ Connecting to the database
✨ Creating server
✅ GraphQL API ready
✨ Generating Admin UI code
✨ Preparing Admin UI app
event - compiled client and server successfully in 10.4s (1500 modules)
Attention: Next.js now collects completely anonymous telemetry regarding usage.
This information is used to shape Next.js' roadmap and prioritize features.
You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
https://nextjs.org/telemetry

✅ Admin UI ready
wait - compiling /api/__keystone_api_build...
error - ../../../../usr/local/lib/node_modules/smartshape_license_nodejs/smartshape_license_nodejs.linux-x64-gnu.node
Module parse failed: Unexpected character '' (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
```

I did not find how to customize Webpack in the KeystoneJS documentation.

- KeystoneJS: 6
- NodeJS: 16.x

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the KeystoneJS 6 Admin UI build with the supplied smartshape_license_nodejs .node module and inspect the Next.js/Webpack handling used by the generated API and Admin UI. Done means the app builds and runs normally without the native-module loader error.

Written by the indexing model from the issue text.

Assessment

Tech stack
next.js, node.js, typescript, webpack
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.