nitin42 / terminal-in-react

👨‍💻 A component that renders a terminal
http://terminal-in-react.surge.sh/
MIT License
2.13k stars 151 forks source link

Internal server error: Failed to resolve entry for package "terminal-in-react". w/Vite #109

Open UI369 opened 1 year ago

UI369 commented 1 year ago

Attempting to use the library with a new app. Tried it with CRA, didn't work, switched to Vite, another error.

I want to create an app with basically just this library, what's the happy path to making it work?

Internal server error: Failed to resolve entry for package "terminal-in-react". The package may have incorrect main/module/exports specified in its package.json.

my package.json:

{
  "name": "hooprunner",
  "private": true,
  "version": "0.0.0",
  "type": "module",
  "scripts": {
    "dev": "vite",
    "build": "tsc && vite build",
    "preview": "vite preview"
  },
  "dependencies": {
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "terminal-in-react": "^4.3.1"
  },
  "devDependencies": {
    "@types/react": "^18.0.27",
    "@types/react-dom": "^18.0.10",
    "@vitejs/plugin-react": "^3.1.0",
    "typescript": "^4.9.3",
    "vite": "^4.1.0"
  }
}

vite.config.ts:

import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [react()],
})
UI369 commented 1 year ago

Full errror:


5:44:11 PM [vite] Internal server error: Failed to resolve entry for package "terminal-in-react". The package may have incorrect main/module/exports specified in its package.json.
  Plugin: vite:import-analysis
  File: /Users/ui369/Workspace/Code/UI369/hooprunner/src/App.js
      at packageEntryFailure (file:///Users/ui369/Workspace/Code/UI369/hooprunner/node_modules/vite/dist/node/chunks/dep-3007b26d.js:22004:11)
      at resolvePackageEntry (file:///Users/ui369/Workspace/Code/UI369/hooprunner/node_modules/vite/dist/node/chunks/dep-3007b26d.js:22001:5)
      at tryNodeResolve (file:///Users/ui369/Workspace/Code/UI369/hooprunner/node_modules/vite/dist/node/chunks/dep-3007b26d.js:21736:20)
      at Context.resolveId (file:///Users/ui369/Workspace/Code/UI369/hooprunner/node_modules/vite/dist/node/chunks/dep-3007b26d.js:21487:28)
      at async Object.resolveId (file:///Users/ui369/Workspace/Code/UI369/hooprunner/node_modules/vite/dist/node/chunks/dep-3007b26d.js:41587:32)
      at async TransformContext.resolve (file:///Users/ui369/Workspace/Code/UI369/hooprunner/node_modules/vite/dist/node/chunks/dep-3007b26d.js:41334:23)
      at async normalizeUrl (file:///Users/ui369/Workspace/Code/UI369/hooprunner/node_modules/vite/dist/node/chunks/dep-3007b26d.js:39685:34)
      at async TransformContext.transform (file:///Users/ui369/Workspace/Code/UI369/hooprunner/node_modules/vite/dist/node/chunks/dep-3007b26d.js:39826:47)
      at async Object.transform (file:///Users/ui369/Workspace/Code/UI369/hooprunner/node_modules/vite/dist/node/chunks/dep-3007b26d.js:41660:30)
      at async loadAndTransform (file:///Users/ui369/Workspace/Code/UI369/hooprunner/node_modules/vite/dist/node/chunks/dep-3007b26d.js:39466:29)```
unional commented 1 year ago

The package does not include the src folder.

sahinme commented 7 months ago

If anyone faced with this issue you can fix it for now importing bundle js

import Terminal from "terminal-in-react/lib/bundle/terminal-react";