Bosko Skrbina
Bosko Skrbina

Reputation: 743

cannot find module "lodash"

Today I tried to learn more about Google Web Starter Kit so I followed these instructions and after a lot of fight and problem I just tried to start a local server (the first task we’ll look at is: $ gulp serve.) and received this error:

C:\gwsk>gulp serve

Error: Cannot find module 'lodash'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (C:\gwsk\node_modules\browser-sync\node_modules\portsc
anner-plus\lib\index.js:3:9)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (C:\gwsk\node_modules\browser-sync\lib\utils.js:6:19)

Honestly I'm completely lost here, so any help is pretty welcome. I'm new to node.js, to gulp, I just wanted it to try GWSK but turn into a headache :(... I'm a web designer not developer....

Upvotes: 72

Views: 258294

Answers (8)

bohem.be
bohem.be

Reputation: 1843

Be sure to install lodash in the required folder. This is probably your C:\gwsk directory.

If that folder has a package.json file, it is also best to add --save behind the install command.

$ npm install lodash --save

The package.json file holds information about the project, but to keep it simple, it holds your project dependencies.

The save command will add the installed module to the project dependencies.

If the package.json file exists, and if it contains the lodash dependency you could try to remove the node_modules folder and run following command:

$ npm cache clean    
$ npm install

The first command will clean the npm cache. (just to be sure) The second command will install all (missing) dependencies of the project.

Upvotes: 134

Jay Byford-Rew
Jay Byford-Rew

Reputation: 6024

I found deleting the contents of node_modules and performing npm install again worked for me.

Upvotes: 19

G.yx
G.yx

Reputation: 673

For me, I update node and npm to the latest version and it works.

Upvotes: 0

Yoweli Kachala
Yoweli Kachala

Reputation: 423

though npm install lodash would work, I think that it's a quick solution but there is a possibility that there are other modules not correctly installed in browser-sync.

lodash is part of browser-sync. The best solution is the one provided by Saebyeok. Re-install browser-sync and that should fix the problem.

Upvotes: 1

aircraft
aircraft

Reputation: 26886

If there is a package.json, and in it there is lodash configuration in it. then you should:

npm install

if in the package.json there is no lodash:

npm install --save-dev

Upvotes: 3

mahesh
mahesh

Reputation: 1

The above error run the commend line\

please change the command $ node server it's working and server is started

Upvotes: -1

Saebyeok
Saebyeok

Reputation: 124

Reinstall 'browser-sync' :

rm -rf node_modules/browser-sync
npm install browser-sync --save

Upvotes: 10

Will Shaver
Will Shaver

Reputation: 13081

Maybe loadash needs to be installed. Usually these things are handled by the package manager. On your command line:

npm install lodash 

or maybe it needs to be globally installed

npm install -g lodash

Upvotes: 9

Related Questions