tailwindcss-forms: Cannot find module 'tailwindcss/plugin'
I’m getting this error when building a project with:
{
"devDependencies": {
"@tailwindcss/forms": "^0.2.1",
"tailwindcss": "^2.0.2"
}
}
tailwind.config.js
:
module.exports = {
plugins: [require("@tailwindcss/forms")],
}
ERROR in ./src/web/css/index.scss
Module build failed (from ../../node_modules/mini-css-extract-plugin/dist/loader.js):
ModuleBuildError: Module build failed (from ./node_modules/postcss-loader/dist/cjs.js):
Error: Cannot find module 'tailwindcss/plugin'
Require stack:
- PROJECT_DIR/node_modules/@tailwindcss/forms/src/index.js
- PROJECT_DIR/projects/Frontend/tailwind.config.js
- PROJECT_DIR/projects/Frontend/node_modules/tailwindcss/lib/index.js
- PROJECT_DIR/projects/Frontend/postcss.config.js
- PROJECT_DIR/projects/Frontend/node_modules/cosmiconfig/dist/loaders.js
- PROJECT_DIR/projects/Frontend/node_modules/cosmiconfig/dist/ExplorerBase.js
- PROJECT_DIR/projects/Frontend/node_modules/cosmiconfig/dist/Explorer.js
- PROJECT_DIR/projects/Frontend/node_modules/cosmiconfig/dist/index.js
- PROJECT_DIR/projects/Frontend/node_modules/postcss-loader/dist/utils.js
- PROJECT_DIR/projects/Frontend/node_modules/postcss-loader/dist/index.js
- PROJECT_DIR/projects/Frontend/node_modules/postcss-loader/dist/cjs.js
- PROJECT_DIR/node_modules/loader-runner/lib/loadLoader.js
- PROJECT_DIR/node_modules/loader-runner/lib/LoaderRunner.js
- PROJECT_DIR/node_modules/webpack/lib/NormalModule.js
- PROJECT_DIR/node_modules/webpack/lib/LoaderTargetPlugin.js
- PROJECT_DIR/node_modules/html-webpack-plugin/lib/child-compiler.js
- PROJECT_DIR/node_modules/html-webpack-plugin/lib/cached-child-compiler.js
- PROJECT_DIR/node_modules/html-webpack-plugin/index.js
- PROJECT_DIR/projects/Frontend/webpack-configs/webpack-common-config.ts
- PROJECT_DIR/projects/Frontend/webpack.config.ts
- PROJECT_DIR/node_modules/webpack-cli/lib/groups/ConfigGroup.js
- PROJECT_DIR/node_modules/webpack-cli/lib/webpack-cli.js
- PROJECT_DIR/node_modules/webpack-cli/lib/bootstrap.js
- PROJECT_DIR/node_modules/webpack-cli/bin/cli.js
- PROJECT_DIR/node_modules/webpack/bin/webpack.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:925:15)
at Function.Module._load (node:internal/modules/cjs/loader:769:27)
at Module.require (node:internal/modules/cjs/loader:997:19)
at require (PROJECT_DIR/node_modules/webpack-cli/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
at Object.<anonymous> (PROJECT_DIR/node_modules/@tailwindcss/forms/src/index.js:2:16)
at Module._compile (PROJECT_DIR/node_modules/webpack-cli/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1137:10)
at Module.load (node:internal/modules/cjs/loader:973:32)
at Function.Module._load (node:internal/modules/cjs/loader:813:14)
at Module.require (node:internal/modules/cjs/loader:997:19)
at processResult (PROJECT_DIR/node_modules/webpack/lib/NormalModule.js:582:19)
at PROJECT_DIR/node_modules/webpack/lib/NormalModule.js:675:5
at PROJECT_DIR/node_modules/loader-runner/lib/LoaderRunner.js:397:11
at PROJECT_DIR/node_modules/loader-runner/lib/LoaderRunner.js:252:18
at context.callback (PROJECT_DIR/node_modules/loader-runner/lib/LoaderRunner.js:124:13)
at Object.loader (PROJECT_DIR/projects/Frontend/node_modules/postcss-loader/dist/index.js:103:7)
@ ./src/web/index.tsx 5:0-26
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 22
- Comments: 56 (3 by maintainers)
Commits related to this issue
- mark tailwindcss as a peerDependency Internally we are using tailwindcss/plugin, but we don't mark it as a peerDependency or a normal dependency in our package.json. This means that this plugin will ... — committed to tailwindlabs/tailwindcss-forms by RobinMalfait 3 years ago
- mark tailwindcss as a peerDependency Internally we are using tailwindcss/plugin, but we don't mark it as a peerDependency or a normal dependency in our package.json. This means that this plugin will ... — committed to tailwindlabs/tailwindcss-forms by RobinMalfait 3 years ago
- fix: fix tailwind+monorepo error Error: Cannot find module 'tailwindcss/plugin' Solution from https://github.com/tailwindlabs/tailwindcss-forms/issues/31#issuecomment-753482779 — committed to AmazeeLabs/silverback-mono by Leksat 3 years ago
- fix: fix tailwind+monorepo error Error: Cannot find module 'tailwindcss/plugin' Solution from https://github.com/tailwindlabs/tailwindcss-forms/issues/31#issuecomment-779139740 — committed to AmazeeLabs/silverback-mono by Leksat 3 years ago
- fix: fix tailwind+monorepo error Error: Cannot find module 'tailwindcss/plugin' Solution from https://github.com/tailwindlabs/tailwindcss-forms/issues/31#issuecomment-779139740 — committed to AmazeeLabs/silverback-mono by Leksat 3 years ago
- fix 'tailwindcss/colors' import error caused by new yarn workspace behaviour (https://github.com/tailwindlabs/tailwindcss-forms/issues/31#issuecomment-763461787) add tailwindcss to dependencies as t... — committed to phivk/gradu.al by phivk 2 years ago
- chore: adding dependencies to circumvent github build fail https://github.com/tailwindlabs/tailwindcss-forms/issues/31#issuecomment-763461787 — committed to samuelstroschein/pankow-ui by samuelstroschein 2 years ago
for me the only thing that worked is to install manually each plugin via npm (following instructions from plugin githup page):
npm install @tailwindcss/typography
and so on with all the plugin that i needed…
For anyone having this issue using Yarn workspaces, run this command in your project root:
yarn add -W tailwindcss@latest postcss@latest autoprefixer@latest
This will make the modules accessible to
tailwind.config.js
in all of the workspaces. In the future, it would be nice if the config file would automatically detect that you’re in a workspace and look fortailwindcss/plugins
in the adjacentnode_modules
directory, but this is a good quick fix 😃I deleted all “node_modules” folders and re-installed all dependencies, and all plugins worked properly!
Maybe it is not a Tailwind CSS plugin issue.
This seemed to work locally for me but not in Production. Kind of silly, but the reason this was happening was: I had my tailwindcss plugin installed as a dev dependency in package.json. Since I don’t install dev dependencies in Production, running
npm run build
failed every time. Once I added my plugin as a main dependency, the build worked as expected.I tried to replicate the issue here but wasn’t able to: https://github.com/mnk179/tailwind-forms
However, it seems to me that this has something to do with dependency resolution in my monorepo setup. I added:
to my
package.json
and that seems to have solved the issue.I was getting this same error when using Tailwind CSS in a Nuxt.js app.
There were no issues on my development PC where the app was set up using create-nuxt app, however, I’d get
Error: Cannot find module 'tailwindcss/plugin'
when trying to runnpm run generate
on my production service (Netlify).The solution was to manually install Tailwind CSS:
npm i -D tailwindcss
Note that create-nuxt-app does define
@nuxtjs/tailwindcss
as a dev dependency, but that’s not enough when actually generating/building the site on a machine that you didn’t set up using create-nuxt-app.Got same error , but ran
npm i
and it resolved itself…I got the error
Error: Cannot find module 'tailwindcss/plugin'
after adding@tailwindcss/forms
to a package in my lerna monorepo.The problem (what I could figure out; please correct me if this is wrong):
@tailwindcss/forms
and Tailwindcss plugins, in general, require theplugin.js
script fromtailwindcss
itself. I guess there is arequire('tailwindcss/plugin')
. In a hoisted monorepo, this fails if thetailwindcss
is not installed in the same folder as the plugin (@tailwindcss/forms
in my case).The workaround (what worked for me consistently): in the root package.json, add
I had to delete all
node_modules
(root and from packages) and ran aninstall
. This will ensure thattailwindcss
and@tailwindcss/**
(plugins) are in the same folder. You can read more about thenohoist
here.Real solution (for tailwindcss maintainers): find a way to import that plugin.js in a hoist-compatible fashion.
@bellcc This problem mostly occurs in a yarn workspaces environment.
I’m getting this error when building a project with:
“devDependencies”: { “@iconify/react”: “^3.0.1”, “autoprefixer”: “^9.8.6”, “postcss”: “^7.0.36”, “tailwindcss”: “npm:@tailwindcss/postcss7-compat@^2.2.7” }
tailwind.config.js:
module.exports = { purge: [],
}
-----> Building on the Heroku-20 stack
-----> Using buildpack: heroku/nodejs
-----> Node.js app detected
-----> Creating runtime environment
-----> Installing binaries
-----> Restoring cache
-----> Installing dependencies
-----> Build
(node:2968) UnhandledPromiseRejectionWarning: Error: Cannot find module ‘tailwindcss’
Require stack:
/tmp/build_a33bf7e6/frontend/craco.config.js
/tmp/build_a33bf7e6/frontend/node_modules/@craco/craco/lib/config.js
/tmp/build_a33bf7e6/frontend/node_modules/@craco/craco/scripts/build.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
at Function.Module._load (internal/modules/cjs/loader.js:746:27)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:93:18)
at Object.<anonymous> (/tmp/build_a33bf7e6/frontend/craco.config.js:5:23)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions…js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Module.require (internal/modules/cjs/loader.js:974:19)
(Use
node --trace-warnings ...
to show where the warning was created)(node:2968) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag
--unhandled-rejections=strict
(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)(node:2968) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
-----> Caching build
-----> Pruning devDependencies
-----> Build succeeded!
-----> Discovering process types
-----> Compressing…
-----> Launching…
npm i @tailwindcss/forms and then npm run serve
I was experiencing this same issue but got around it. While I had installed tailwindcss into the project I had not explicitly installed tailwindcss/forms. Follow the instructions in this repo and you’ll be up and running again.
https://github.com/tailwindlabs/tailwindcss-forms
Of course
On Wed, 30 Dec 2020 at 18:02, Adam Wathan notifications@github.com wrote:
Ran into this, also in yarn workspaces-based monorepo. The nohoist solution seemed to work for me.
I did notice that it looked like
tailwindcss
was not hoisted (project1/node_modules/tailwindcss
), but@tailwindcss/forms
seemed to be (node_modules/@tailwindcss/forms
). Perhaps@tailwindcss/forms
was attempting to require something from a module that was not present at the root?I’m beginer with tailwind, I followed by documentation. And had same issue. My fix was:
npm install -D @tailwindcss/forms
npm install tw-elements
This fix my issue thank you
Faced the same issue, which got fixed with
npm i
Nuking the repo and recloning it worked in my case. It builds fine now.
Hello, have you tried to remove the node_modules and run the npm install again? Thanks.
From: Raphaël Saunier @.> Sent: Thursday, March 25, 2021 4:21 PM To: tailwindlabs/tailwindcss-forms @.> Cc: Michael Olonan @.>; Comment @.> Subject: Re: [tailwindlabs/tailwindcss-forms] Cannot find module ‘tailwindcss/plugin’ (#31)
@RobinMalfaithttps://github.com/RobinMalfait sorry to bug you again with this problem, but I’m running into the same issue with both Yarn (1.22.10) and NPM (7.6.3) with or without the nohoist configuration value in a monorepo project (even after deleting all node_modules/ folders):
vite v2.1.2 building for production…
✓ 22 modules transformed.
[vite:css] Cannot find module ‘tailwindcss/plugin’
Require stack:
@.***/forms/src/index.js
/PROJECT_DIR/WORKSPACE_DIR/tailwind.config.js
@.***/jit/src/lib/setupContext.js
@.***/jit/src/index.js
/PROJECT_DIR/node_modules/vite/dist/node/chunks/dep-efe32886.js
/PROJECT_DIR/node_modules/vite/dist/node/cli.js
/PROJECT_DIR/node_modules/vite/bin/vite.js
file: /PROJECT_DIR/WORKSPACE_DIR/src/styles.css
error during build:
Error: Cannot find module ‘tailwindcss/plugin’
Require stack:
@.***/forms/src/index.js
/PROJECT_DIR/WORKSPACE_DIR/tailwind.config.js
@.***/jit/src/lib/setupContext.js
@.***/jit/src/index.js
/PROJECT_DIR/node_modules/vite/dist/node/chunks/dep-efe32886.js
/PROJECT_DIR/node_modules/vite/dist/node/cli.js
/PROJECT_DIR/node_modules/vite/bin/vite.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
at Function.Module._load (internal/modules/cjs/loader.js:667:27)
at Module.require (internal/modules/cjs/loader.js:887:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> @.***/forms/src/index.js:2:16)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions…js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Module.require (internal/modules/cjs/loader.js:887:19)
As a workaround, I had to install tailwindcss as a dev dependency in the root package.json, but that doesn’t feel right.
— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/tailwindlabs/tailwindcss-forms/issues/31#issuecomment-806458398, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ASZ74K4SN7CWJ336R3AZAWTTFLXCNANCNFSM4VNLTMEQ.