Next.js Discord

Discord Forum

I have published a package to npm, but when i import it in next, i get dependency issues.

Answered
adam.birds posted this in #help-forum
Open in Discord
I have just published this package to npm: https://www.npmjs.com/package/tablewind

However when installing I am getting the error:

Build Error
Next.js (15.1.7)
Failed to compile

../node_modules/tablewind/dist/src/components/BulkActionModal.js:3:1
Module not found: Can't resolve '@headlessui/react'
  1 | import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
  2 | import { Fragment } from 'react';
> 3 | import { Dialog, Transition } from '@headlessui/react';


So I tried adding it to transpilePackages but that just changed it to:

Failed to compile

../node_modules/tablewind/dist/src/components/BulkActionModal.js:2:1
Module not found: Can't resolve '@headlessui/react'

https://nextjs.org/docs/messages/module-not-found

Import trace for requested module:
../node_modules/tablewind/dist/src/components/DataTable.js
../node_modules/tablewind/dist/src/next.js
./src/app/dashboard/posts/page.tsx


And I'm not sure whats going wrong, it is listed inpeerDependencies of the package and is installed in my application.

My app package.json:
{
    "name": "debuglife-frontend",
    "version": "0.1.0",
    "private": true,
    "scripts": {
        "dev": "next dev",
        "build": "next build",
        "start": "next start",
        "lint": "next lint"
    },
    "dependencies": {
        "@apollo/client": "^3.13.1",
        "@apollo/experimental-nextjs-app-support": "^0.11.9",
        "@headlessui/react": "^2.2.0",
        "@headlessui/tailwindcss": "^0.2.2",
        "@heroicons/react": "^2.2.0",
        "@icons-pack/react-simple-icons": "^11.2.0",
        "@milkdown/crepe": "^7.6.3",
        "@milkdown/kit": "^7.6.3",
        "@milkdown/plugin-emoji": "^7.6.3",
        "@milkdown/react": "^7.6.3",
        "@milkdown/theme-nord": "^7.6.3",
        "@prosemirror-adapter/react": "^0.4.0",
        "@types/node": "^22.13.4",
        "@types/react-dom": "^19.0.4",
        "compromise": "^14.14.4",
        "cookies-next": "^5.1.0",
        "eslint": "^9.20.1",
        "eslint-config-next": "^15.1.7",
        "headlessui": "^0.0.0",
        "heroicons": "^2.2.0",
        "next": "^15.1.7",
        "next-themes": "^0.4.4",
        "react": "^19.0.0",
        "react-dom": "^19.0.0",
        "react-icons": "^5.4.0",
        "swr": "^2.3.2",
        "tablewind": "^1.0.1",
        "typescript": "^5.7.3"
    },
    "devDependencies": {
        "@tailwindcss/aspect-ratio": "^0.4.2",
        "@tailwindcss/forms": "^0.5.10",
        "@tailwindcss/postcss": "^4.0.6",
        "@types/react": "19.0.8",
        "postcss": "^8.5.2",
        "tailwindcss": "^4.0.6"
    },
    "optionalDependencies": {
        "@tailwindcss/oxide-linux-arm64-gnu": "^4.0.6",
        "lightningcss-linux-arm64-gnu": "^1.29.1"
    }
}


My library package.json: https://github.com/adambirds/tablewind/blob/main/package.json
Answered by adam.birds
Ended up solving. Switched to using rollup to package.
View full answer

1 Reply

Ended up solving. Switched to using rollup to package.
Answer