Reputation: 4671
My grunt
task seems to be running perfectly fine, but every time I run it I'm getting this error:
Loading "jshint.js" tasks...ERROR
>> Error: Cannot find module 'underscore'
Is there any way to find out why this is happening? I can see the /grunt-contrib-jshint
directory is in the /node_modules
directory. Is there any reason it can't find the underscore
module? I've tried running npm install
but I still get the same error when I run grunt.
Any ideas? Any help is appreciated.
Upvotes: 10
Views: 28828
Reputation: 20232
If you are using Magento 2, then make sure that you did not accidentially deleted the file "package.json". If the file exist, then execute:
npm remove -g grunt grunt-cli && npm install -g grunt grunt-cli && npm install grunt --save-dev && npm install
Then you can test with
grunt refresh
Upvotes: 0
Reputation: 31
Do the following:
npm update
npm install underscore
If that doesn't work do the following.
rm -rf node_modules
npm install -d
npm update
Upvotes: 3
Reputation: 3418
When you have cannot find module x errors
, one thing that might help sometimes is deleting the whole npm_modules
folder and just running npm install
again.
Sometimes, on the initial npm install
, it might of failed to get one dependency for a package and it won't try to get it again when you run npm install
again, as it got all of the packages you wanted, just maybe not all the dependencies of those packages.
Upvotes: 23