The Old County
The Old County

Reputation: 89

Cannot find module 'classnames'

I am getting the following error when I try and run grunt on a react project

$ grunt server Running "browserify:dist" (browserify) task

Error: Cannot find module 'classnames' from 'd:\wamp\www\react1\app\assets\js \components' Warning: Error running grunt-browserify. Use --force to continue.

Aborted due to warnings.

Upvotes: 14

Views: 40063

Answers (3)

scil
scil

Reputation: 307

if you are using pnpm, maybe you need shamefully-hoist = true

Upvotes: 0

Amir M. Mohamadi
Amir M. Mohamadi

Reputation: 1512

First, install it with npm install classnames. In Windows, everything will be fine if you write

import classNames from 'classnames'

but in Linux, I got this error that 'classnames' is not defined... and the problem was the capital letter I wrote 'classNames' instead of 'classnames' for module import, so consider that it might solve your problem.

Upvotes: 10

agmcleod
agmcleod

Reputation: 13621

You should post your package.json file, and the code of which file is trying to pull class names. That said it sounds like you're simply missing a dependency.

npm install classnames --save

Will add it to your package.json file and install it in node_modules. Re-run your grunt server after installing or updating any npm packages.

Upvotes: 37

Related Questions