MasterKale / SimpleWebAuthn

WebAuthn, Simplified. A collection of TypeScript-first libraries for simpler WebAuthn integration. Supports modern browsers, Node, Deno, and more.
https://simplewebauthn.dev
MIT License
1.62k stars 137 forks source link

Warn: Module not found: Can't resolve 'encoding ' #461

Closed renchris closed 1 year ago

renchris commented 1 year ago

Describe the issue

During runtime, I get a warning message of:

- warn ./node_modules/.pnpm/node-fetch@2.6.11/node_modules/node-fetch/lib/index.js
Module not found: Can't resolve 'encoding' in '/node_modules/.pnpm/node-fetch@2.6.11/node_modules/node-fetch/lib'

Import trace for requested module:
./node_modules/.pnpm/node-fetch@2.6.11/node_modules/node-fetch/lib/index.js
./node_modules/.pnpm/cross-fetch@3.1.6/node_modules/cross-fetch/dist/node-ponyfill.js
./node_modules/.pnpm/@simplewebauthn+server@7.3.1/node_modules/@simplewebauthn/server/dist/services/metadataService.js
./node_modules/.pnpm/@simplewebauthn+server@7.3.1/node_modules/@simplewebauthn/server/dist/index.js
./lib/login.ts

./node_modules/.pnpm/node-fetch@2.6.11/node_modules/node-fetch/lib/index.js
Module not found: Can't resolve 'encoding' in '/node_modules/.pnpm/node-fetch@2.6.11/node_modules/node-fetch/lib'

Expected behavior

I expect that this warning should not have shown as having @simplewebauthn/server as the project dependency should self-contain all its own dependencies.

Code Samples + WebAuthn Options and Responses

The imports I have in login.ts from @simplewebauthn/server are

import type {
  VerifiedAuthenticationResponse,
  GenerateAuthenticationOptionsOpts,
  VerifyAuthenticationResponseOpts,
} from '@simplewebauthn/server'
import {
  verifyAuthenticationResponse,
  generateAuthenticationOptions,
} from '@simplewebauthn/server'

Dependencies

SimpleWebAuthn Libraries

@simplewebauthn/browser 7.2.0
@simplewebauthn/server 7.3.1
@simplewebauthn/typescript-types 7.0.0

Additional context

I can fix this by installing 'encode' as a dependency of my project with the command pnpm add -D encoding but my understanding @simplewebauthn/server should already have 'encode' as its own dependency

I am using NextJS App Router and my login.ts file is a 'use server' file.

This warning shows up on page renders before any button is pressed to run any function.

MasterKale commented 1 year ago

Hmm, I tried to use a barebones project repo using pnpm to install dependencies, but I wasn't able to recreate the issue you're encountering. I'm going to need you to help me out here with a basic reproduction repo that can recreate this, especially since you mentioned that you're experiencing this in your NextJS project.

Once I have something that can pull down locally to reproduce the problem is as basic a NextJS project as you can manage then I'll probably have a shot at figuring out what's going on here.

MasterKale commented 1 year ago

Three weeks out and there's been no follow-up so I'm closing this out for now. Please feel free to reopen if you can provide a minimal reproduction that I can use to reproduce this locally.