i-like-robots / react-tag-autocomplete

⚛️ A simple, accessible, tagging component ready to drop into your React projects (new repo)
https://i-like-robots.github.io/react-tag-autocomplete/
ISC License
178 stars 12 forks source link

Unable to import react-tag-autocomplete in a Remix project #10

Closed lpsinger closed 2 years ago

lpsinger commented 2 years ago

I cannot import react-tag-autocomplete in a barebones Remix project created from the create-remix template.

Here is my example project: https://github.com/lpsinger/remix-react-tag-autocomplete

When I run npm run build in the example project, I get:

The path "react-tag-autocomplete" is imported in app/lib/CountrySelector.tsx but "react-tag-autocomplete" was not found in your node_modules. Did you forget to install it?

When I run npm run dev, the ReactTags example does not load, and I get this error message displayed in the browser:

Error

Process exited with 1

node:internal/modules/cjs/loader:936
  throw err;
  ^

Error: Cannot find module 'react-tag-autocomplete'
Require stack:
- /Users/lpsinger/src/my-remix-app/server/index.js
- /Users/lpsinger/src/my-remix-app/server/[eval]
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object. (/Users/lpsinger/src/my-remix-app/app/lib/CountrySelector.tsx:3:27)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
i-like-robots commented 2 years ago

Thank you for your detailed report and example. There is currently no CommonJS version of the package being built nor a main field specified in the manifest so that's why Node's module resolution step is failing as shown by the stack trace provided. This is just an oversight on my part (I don't currently have any projects using the component without a build and bundle step) so I'll get that sorted ASAP.

i-like-robots commented 2 years ago

I have added a CommonJS bundle to the package in c7014958699ac63ea031e2643fc350ee32931552 and this change is included in v7.0.0-beta.8 now available on NPM.

lpsinger commented 2 years ago

It works now. Thanks!