49

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....

Oleg
  • 8,818
  • 2
  • 40
  • 55
Bosko Skrbina
  • 513
  • 1
  • 4
  • 5

9 Answers9

110

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.

Hope this helps you understand the node package manager a little bit more.

Eduardo Dennis
  • 12,511
  • 11
  • 72
  • 102
bohem.be
  • 1,577
  • 1
  • 13
  • 17
  • Hi bohem, to be honest I just forget about this and move on, any way thx a lot for your answer! I will bookmark it and give it a try in a near future ;) for now trying sass + susy + breakpoint. :D – Bosko Skrbina Feb 13 '15 at 16:59
  • No problem, I got a web designer sitting behind me and know how hard it can be for none developers to understand technical explanations so tried to keep it superficial. Give a shout when you got it to work or not. Always wanted to try gulp ;) – bohem.be Feb 13 '15 at 17:43
  • As of npm v5 you can run 'npm cache verify'. Although the exact equivalent would be 'npm cache clean --force' – StLia Aug 03 '17 at 16:02
11

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

kernowcode
  • 4,768
  • 31
  • 33
5

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
Will Shaver
  • 10,683
  • 5
  • 44
  • 62
  • 1
    Hi Will! thx for your answer. I tryed what you suggest and recieve a lot of "npm WARN unmet dependency undefined,npm WARN unmet dependency which is version undefined." :( I try again to run gulp serve and fail again... Now say this: "Starting 'styles' errored after 13 s, Error: Cannot find module 'gulp-util'" – Bosko Skrbina Dec 11 '14 at 20:14
5

Reinstall 'browser-sync' :

rm -rf node_modules/browser-sync
npm install browser-sync --save
Saebyeok
  • 74
  • 1
  • 3
3

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
aircraft
  • 16,211
  • 16
  • 74
  • 135
0

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

G.yx
  • 373
  • 2
  • 4
  • 12
0

I got the error above and after fixing it I got an error for lodash/merge, then I got an error for 'license-check-and-add' then I realized that according to https://accessibilityinsights.io if I ran the below command, it installs all the missing pacakages at once! Then running the yarn build command worked smoothly with a --force parameter with yarn build.

yarn install

yarn build --force

enter image description here

Yarn build --force execution: enter image description here

aditya
  • 433
  • 1
  • 5
  • 11
-1

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.

Adrita Sharma
  • 17,967
  • 8
  • 40
  • 61
Yoweli Kachala
  • 393
  • 5
  • 13
-1

The above error run the commend line\

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

mahesh
  • 1