Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module not found in Next13 #837

Open
Nfinished opened this issue Apr 13, 2023 · 4 comments · May be fixed by #847
Open

Module not found in Next13 #837

Nfinished opened this issue Apr 13, 2023 · 4 comments · May be fixed by #847

Comments

@Nfinished
Copy link

Node v18.12.1
Next v13.3.0
pnpm v 8.1.1

segment.ts is poisoned with client-only
Segment.tsx is a client component

warn  - ./node_modules/.pnpm/[email protected]/node_modules/node-fetch/lib/index.js
Module not found: Can't resolve 'encoding' in '/home/nfinished/upwell.gg/node_modules/.pnpm/[email protected]/node_modules/node-fetch/lib'

Import trace for requested module:
./node_modules/.pnpm/[email protected]/node_modules/node-fetch/lib/index.js
./node_modules/.pnpm/@[email protected]/node_modules/@segment/analytics-next/dist/cjs/plugins/analytics-node/index.js
./node_modules/.pnpm/@[email protected]/node_modules/@segment/analytics-next/dist/cjs/node/index.js
./node_modules/.pnpm/@[email protected]/node_modules/@segment/analytics-next/dist/cjs/index.js
./utils/segment.ts
./app/Segment.tsx
@silesky
Copy link
Contributor

silesky commented Apr 13, 2023

Hi. Can you show your code? What module are you trying to import?

@Nfinished
Copy link
Author

Sorry, dunno why I didn't include it to begin with.

// segment.ts
import { AnalyticsBrowser } from '@segment/analytics-next'

import 'client-only'

const segment = AnalyticsBrowser.load({
  writeKey: process.env.NEXT_PUBLIC_SEGMENT_WRITE_KEY as string,
})

export default segment
// Segment.tsx
'use client'

import '@/utils/segment'

export default function Segment() {
  return null
}

@silesky
Copy link
Contributor

silesky commented Apr 16, 2023

Thanks. Haven't had time to look into this yet, but FYI: all node stuff is getting deleted from this package in around a month, maybe sooner. Pretty sure that will fix the issue.

@knajjars
Copy link

knajjars commented May 2, 2024

Has this been fixed @silesky?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants