Error: Cannot find module 'browser-sync'
Asked Answered
F

4

19

When am trying to start gulp serve Its raise an error

module.js:338 throw err; ^

Error: Cannot find module 'browser-sync'

at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/home/sajad/p_projects/my-project/gulpfile.js:17:19)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)

After that i tried sudo npm rm browser-sync && npm install browser-sync its raise follwing error

npm ERR! Linux 3.13.0-24-generic

npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" "browser-sync" npm ERR! node v0.12.7 npm ERR! npm v2.11.3 npm ERR! file /home/sajad/.npm/escape-html/1.0.2/package/package.json npm ERR! code EJSONPARSE

npm ERR! Failed to parse json npm ERR! No data, empty input at 1:1 npm ERR! npm ERR! ^ npm ERR! File: /home/sajad/.npm/escape-html/1.0.2/package/package.json npm ERR! Failed to parse package.json data. npm ERR! package.json must be actual JSON, not just JavaScript. npm ERR! npm ERR! This is not a bug in npm. npm ERR! Tell the package author to fix their package.json file. JSON.parse

npm ERR! Please include the following file with any support request: npm ERR! /home/sajad/p_projects/my-project/npm-debug.log

Guide me how to start gulp serve and how resolve these error

Franchot answered 18/10, 2015 at 16:26 Comment(0)
F
15

I tried these steps. Its work for me.

Globally install gulp.

Next need to install the project’s local dependencies (that’s where it’s looking for browser-sync). To do that,

cd into the project directory and run npm install.

Then try gulp serve.

You can also try following lines

npm i browser-sync --save 

then

npm start
Franchot answered 18/10, 2015 at 17:22 Comment(1)
For me the problem was that I was installing using --save-dev, using just --save solved. Thanks!Aniakudo
P
34

I also had a same problem, I was able to solve it by entering this.

npm i browser-sync --save

Check this link here: https://github.com/brawlins/react-webpack-php-starter/issues/1

Pansie answered 11/10, 2016 at 12:57 Comment(1)
For me the problem was that I was installing using --save-dev, removing it from devDependencies and install using just --save solved. Thanks!Aniakudo
F
15

I tried these steps. Its work for me.

Globally install gulp.

Next need to install the project’s local dependencies (that’s where it’s looking for browser-sync). To do that,

cd into the project directory and run npm install.

Then try gulp serve.

You can also try following lines

npm i browser-sync --save 

then

npm start
Franchot answered 18/10, 2015 at 17:22 Comment(1)
For me the problem was that I was installing using --save-dev, using just --save solved. Thanks!Aniakudo
S
10

You can try a :

npm cache clean 

as it looks like it's not related to your project but your npm files, and then re run npm install

Schematize answered 3/3, 2016 at 16:4 Comment(1)
This was the solution for me, only I had to add --force to the above cache clean statement, which solved the problem.Kanya
G
0

Are you behind a proxy? Because it happened once to me in a company, this specific node module wouldn't be installed because of the proxy. I had to install it without proxy to make it work. Just try on your phone or another network.

Graybeard answered 18/10, 2015 at 16:35 Comment(1)
But i stop my proxy - i reinstalled but same issueFranchot

© 2022 - 2024 — McMap. All rights reserved.