Hello guys,
- I ran into the exactly same problem when using JHipster as well, when in package.json : «browser-sync»: «2.27.9», and when run npm install first time (no node_modules exists), it will generate package-lock.json with this dependency of browser-sync-client
«browser-sync-client»: {
«version»: «2.27.10»,
«resolved»: «https://registry.npmjs.org/browser-sync-client/-/browser-sync-client-2.27.10.tgz»,
«integrity»: «sha512-KCFKA1YDj6cNul0VsA28apohtBsdk5Wv8T82ClOZPZMZWxPj4Ny5AUbrj9UlAb/k6pdxE5HABrWDhP9+cjt4HQ==»,
«dev»: true,
«requires»: {
«etag»: «1.8.1»,
«fresh»: «0.5.2»,
«mitt»: «^1.1.3»,
«rxjs»: «^5.5.6»,
«typescript»: «^4.6.2»
},
- And here comes the problem with missing index.min.js in browser-sync-client:2.27.10 . You guys can double check by download gz file from: https://registry.npmjs.org/browser-sync-client/-/browser-sync-client-2.27.10.tgz and see the problem. This is the full error log I got:
Error: Cannot find module ‘browser-sync-client/dist/index.min.js’
Require stack:
-myproject/node_modules/browser-sync/dist/snippet.js
-myproject/node_modules/browser-sync/dist/hooks.js
-myproject/node_modules/browser-sync/dist/browser-sync.js
-myproject/node_modules/browser-sync/dist/index.js
-myproject/node_modules/browser-sync-webpack-plugin/lib/BrowserSyncPlugin.js
-myproject/node_modules/browser-sync-webpack-plugin/index.js
-myproject/webpack/webpack.custom.js
-myproject/node_modules/@angular-builders/custom-webpack/dist/utils.js
-myproject/node_modules/@angular-builders/custom-webpack/dist/custom-webpack-builder.js
-myproject/node_modules/@angular-builders/custom-webpack/dist/transform-factories.js
-myproject/node_modules/@angular-builders/custom-webpack/dist/generic-browser-builder.js
-myproject/node_modules/@angular-builders/custom-webpack/dist/dev-server/index.js
-myproject/node_modules/@angular/cli/node_modules/@angular-devkit/architect/node/node-modules-architect-host.js
-myproject/node_modules/@angular/cli/node_modules/@angular-devkit/architect/node/index.js
-myproject/node_modules/@angular/cli/models/architect-command.js
-myproject/node_modules/@angular/cli/commands/serve-impl.js
-myproject/node_modules/@angular-devkit/schematics/tools/export-ref.js
-myproject/node_modules/@angular-devkit/schematics/tools/index.js
-myproject/node_modules/@angular/cli/utilities/json-schema.js
-myproject/node_modules/@angular/cli/models/command-runner.js
-myproject/node_modules/@angular/cli/lib/cli/index.js
-myproject/node_modules/@angular/cli/lib/init.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
at Function.resolve (internal/modules/cjs/helpers.js:98:19)
atmyproject/node_modules/browser-sync/dist/snippet.js:87:52
atmyproject/node_modules/browser-sync-client/index.js:59:39
at Array.reduce ()
at processItems myproject/node_modules/browser-sync-client/index.js:54:10)
atmyproject/node_modules/browser-sync-client/index.js:89:22
at call myproject/node_modules/connect/index.js:239:7)
at next myproject/node_modules/connect/index.js:183:5)
at next myproject/node_modules/connect/index.js:161:14)
- Note that with version browser-sync-client:2.27.9 , it was OK, no missing index.min.js , the package-lock.json should be like this:
«browser-sync-client»: {
«version»: «2.27.9»,
«resolved»: «https://registry.npmjs.org/browser-sync-client/-/browser-sync-client-2.27.9.tgz»,
«integrity»: «sha512-FHW8kydp7FXo6jnX3gXJCpHAHtWNLK0nx839nnK+boMfMI1n4KZd0+DmTxHBsHsF3OHud4V4jwoN8U5HExMIdQ==»,
«dev»: true,
«requires»: {
«etag»: «1.8.1»,
«fresh»: «0.5.2»,
«mitt»: «^1.1.3»,
«rxjs»: «^5.5.6»
},
-
How I quick fixed the problem: just same as @krmahadevan did, I explicitly put in my package.json the dependency: «browser-sync-client»: «2.27.9». I removed the node_modules folder, and I run the npm install again. Now the package-lock.json will have the browser-sync-client:2.2.7.9 again, and no more error in console :).
-
I believe the best fix must be to fix the release distribution of browser-sync-client-2.27.10.tgz itself.
Содержание
- index.min.js is missing from the latest version #1549
- Comments
- Issue details
- Error: Cannot find module ‘browser-sync’
- Solution
- Related Articles
- Gulp Browser-sync Throwing Error module.js:471 cannot find ./lib/public/resume.js Windows 7 #1306
- Comments
- Issue details
- Please specify which version of Browsersync, node and npm you’re running
- Affected platforms
- Browsersync use-case
- gulpfile.js
- Gulp — Error: cannot find module ‘immutable’ #502
- Comments
- Attempted Solutions
- Full Console Output (errors, immutable-related)
- Running npm install for browser-sync
- When running gulp
- My Repo
- Error: Cannot find module ‘etag’ #1471
- Comments
- Issue details
- Steps to reproduce/test case
- Please specify which version of Browsersync, node and npm you’re running
- Affected platforms
- Browsersync use-case
- If CLI, please paste the entire command below
- for all other use-cases, (gulp, grunt etc), please show us exactly how you’re using Browsersync
index.min.js is missing from the latest version #1549
Issue details
Error: ENOENT: no such file or directory, . node_modulesbrowser-syncclientdistindex.min.js
The text was updated successfully, but these errors were encountered:
Same problem here. Reload/Stream functions suddenly stopped work.
Same issue here, after updating to v2.24.0
Same issue. Error log as follows:
I began to see this error message after upgrading npm to v6.0.0; even with browsersync v2.18.15
But @Carlosdvp , if you check the Git history it was removed in one of the last commits:
You are right @vinceshere I was looking through the node_modules for previous projects that I had been using browsersync with, and they were working fine because the contents for that folder were intact. The cause as far as I can tell is that the contents for the directory you mention are now gone.
To correct my previous comment: It has nothing to do with npm v6.0.0, tested old installs of browser-sync with npm v6 and they work fine
browser-sync/client/dist contents are missing in new installs of browser-sync, that is the cause for this error message. I just copied the missing files into the empty folder and now it’s working fine
Please change this issue’s title to something like:
«index.min.js is missing from the latest version»
Not trying to be a grammar nasty but at least it would be easier to understand if it were «does not» instead of «don’t».
@dhffdh pin your version to the old one «browser-sync»: «2.23.7», .
@huochunpeng THANK YOU =)
Thanks all for the fast feedback 🙂
I had removed the compiled assets from the repo, with the aim of rebuilding them only when publishing — but I used an incorrect NPM lifecycle hook — oops!
It’s fixed now though browser-sync@2.24.1
@shakyShane I like the removal in general.
FYI, but it could create some trouble for some users (like contributors) who directly installs the package from git repo, if they use yarn or pnpm.
@shakyShane Hi, I think this issue might be revived again from the latest release v2.27.10. I ras running v2.27.9 in my projects and started to get this error recently.
@shakyShane Same for me. I started to see this problem (missing index.min.js) when upgrading to v2.27.10.
Same here in my new jHipster project with «browser-sync»: «2.27.9»,
I also experienced the same issue when using JHipster to create a new standalone app using browser-sync version 2.27.9 . For now I have went back to pinning to an older version in the package.json viz., «browser-sync»: «2.24.1»
- I ran into the exactly same problem when using JHipster as well, when in package.json : «browser-sync»: «2.27.9», and when run npm install first time (no node_modules exists), it will generate package-lock.json with this dependency of browser-sync-client
- And here comes the problem with missing index.min.js in browser-sync-client:2.27.10 . You guys can double check by download gz file from: https://registry.npmjs.org/browser-sync-client/-/browser-sync-client-2.27.10.tgz and see the problem. This is the full error log I got:
Error: Cannot find module ‘browser-sync-client/dist/index.min.js’
Require stack:
-myproject/node_modules/browser-sync/dist/snippet.js
-myproject/node_modules/browser-sync/dist/hooks.js
-myproject/node_modules/browser-sync/dist/browser-sync.js
-myproject/node_modules/browser-sync/dist/index.js
-myproject/node_modules/browser-sync-webpack-plugin/lib/BrowserSyncPlugin.js
-myproject/node_modules/browser-sync-webpack-plugin/index.js
-myproject/webpack/webpack.custom.js
-myproject/node_modules/@angular-builders/custom-webpack/dist/utils.js
-myproject/node_modules/@angular-builders/custom-webpack/dist/custom-webpack-builder.js
-myproject/node_modules/@angular-builders/custom-webpack/dist/transform-factories.js
-myproject/node_modules/@angular-builders/custom-webpack/dist/generic-browser-builder.js
-myproject/node_modules/@angular-builders/custom-webpack/dist/dev-server/index.js
-myproject/node_modules/@angular/cli/node_modules/@angular-devkit/architect/node/node-modules-architect-host.js
-myproject/node_modules/@angular/cli/node_modules/@angular-devkit/architect/node/index.js
-myproject/node_modules/@angular/cli/models/architect-command.js
-myproject/node_modules/@angular/cli/commands/serve-impl.js
-myproject/node_modules/@angular-devkit/schematics/tools/export-ref.js
-myproject/node_modules/@angular-devkit/schematics/tools/index.js
-myproject/node_modules/@angular/cli/utilities/json-schema.js
-myproject/node_modules/@angular/cli/models/command-runner.js
-myproject/node_modules/@angular/cli/lib/cli/index.js
-myproject/node_modules/@angular/cli/lib/init.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
at Function.resolve (internal/modules/cjs/helpers.js:98:19)
atmyproject/node_modules/browser-sync/dist/snippet.js:87:52
atmyproject/node_modules/browser-sync-client/index.js:59:39
at Array.reduce ()
at processItems myproject/node_modules/browser-sync-client/index.js:54:10)
atmyproject/node_modules/browser-sync-client/index.js:89:22
at call myproject/node_modules/connect/index.js:239:7)
at next myproject/node_modules/connect/index.js:183:5)
at next myproject/node_modules/connect/index.js:161:14)
- Note that with version browser-sync-client:2.27.9 , it was OK, no missing index.min.js , the package-lock.json should be like this:
How I quick fixed the problem: just same as @krmahadevan did, I explicitly put in my package.json the dependency: «browser-sync-client»: «2.27.9». I removed the node_modules folder, and I run the npm install again. Now the package-lock.json will have the browser-sync-client:2.2.7.9 again, and no more error in console :).
I believe the best fix must be to fix the release distribution of browser-sync-client-2.27.10.tgz itself.
Источник
Error: Cannot find module ‘browser-sync’
Posted By: Anonymous
When am trying to start gulp serve
Its raise an error
Error: Cannot find module ‘browser-sync’
After that i tried sudo npm rm browser-sync && npm install browser-sync
its raise follwing error
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
Solution
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
Answered By: Anonymous
Related Articles
Disclaimer: This content is shared under creative common license cc-by-sa 3.0. It is generated from StackExchange Website Network.
Источник
Gulp Browser-sync Throwing Error module.js:471 cannot find ./lib/public/resume.js Windows 7 #1306
Issue details
Trying to run gulp task and browser-sync is throwing an error — halting the process. Tried npm cache clean, reverting back to previous versions of npm with no luck.
resume.js is present in node_modules/browser-sync/lib/public
The same set up is on my colleague’s computer, but it works! I’ve been at this for several hours and not sure where else to look so I’m opening this issue.
Please specify which version of Browsersync, node and npm you’re running
- Browsersync [ 2.18.7 ]
- Node [ 6.9.4 ]
- Npm [ 4.1.2 ]
- Git Bash win32 x64
- prefix = «C:Users\AppDataRoamingnpm
- node bin location C:Program Filesnodejsnode.exe
- HOME = C:Users
- which npm = /c/Program Files/nodejs/npm
- which node = /c/Program Files/nodejs/node
- $echo NODE_PATH = n/a command not found
Affected platforms
- linux
- windows
- OS X
- freebsd
- solaris
- other (please specify which)
Browsersync use-case
gulpfile.js
The text was updated successfully, but these errors were encountered:
Update: I’m beginning to believe this issue is stemming from some kind of system settings, permissions, or symantec antivirus/firewall restrictions. Upon further testing. Browser-sync was able to be installed and run with the above gulp task in Safe Mode with Networking, but when running in Windows normal mode, that resume.js error is triggered. Please keep this issue open for now as I feel I am getting closer to the culprit. Will report back with what we find.
Does the file exist? Never mind.
I have a related issue because I am not able to create the file ‘resume.js’ anywhere on my machine.
@Pradhyo Interesting. I am experiencing something similar.
Источник
Gulp — Error: cannot find module ‘immutable’ #502
I’m currently using browser-sync as a gulp dev-dependency for an express.js app.
Everything seems to work fine in a local version of this app but when I:
- git clone the repo
- npm install
- npm start or nodemon ./bin/www
- gulp
Running gulp will give me an error that looks related to browser-sync and immutable .
Here’s a truncated error (full errors near the end of the issue):
When I look at the output from install browser-sync by itself, I can see that immutable is installing successfully:
Attempted Solutions
- I’ve tried deleting my node_modules and re-installing all dependencies with npm install but the error still persists.
- In package.json , tried removing ^ and
from dependencies to lock-in versions for npm modules
Running npm install for browser-sync
When running gulp
My Repo
The text was updated successfully, but these errors were encountered:
Happening to me as well, same stack trace.
I don’t know if this will help, since I am running BrowserSync from the command line in Terminal instead of via Gulp, but this is what I needed to do to fix the «Cannot find module ‘immutable’» error message on my system.
I needed to install the «immutable» Node.js module globally using the following command with the «-g» flag so I didn’t get an error telling me it cannot find the module:
npm install -g immutable
I also installed BrowserSync by executing the following command to install it globally:
npm install -g browser-sync
I installed it globally for now, but may install it locally under each project in the future.
This is probably not related, but I also changed the ownership of Node.js files so when installing modules I don’t have to use «sudo» everytime using the following command:
sudo chown -R whoami /usr/local/lib/node_modules
They tell you to change ownership of the full «/usr/local» directory in the npmjs.com documentation, but I didn’t want to do that, so I used the command above following the mawaha.com guide.
Lastly, I read that you may need to add «/usr/local/lib/node_modules/:» to your $PATH variable in the .bash_profile or .profile files by editing it and adding the following line:
I tried this when having problems, but ended up removing it, since installing immutable globally I think resolved the problem. My PATH statement now looks like the following in my .bash_profile file under my home directory in OS X:
I have the PATH set this way so I can use the Homebrew version of Ruby and latest version of Git to load instead of the ones that come with OS X.
I hope this helps, but once again I am not trying to use BrowserSync via Gulp, so none of the above may apply.
Источник
Error: Cannot find module ‘etag’ #1471
Issue details
Issue browser-sync 2.20.0 causes issue with build process. however browser-sync 2.19.0 works correctly
Error seen:
error 21-Dec-2017 16:14:55 module.js:327
error 21-Dec-2017 16:14:55 throw err;
error 21-Dec-2017 16:14:55 ^
error 21-Dec-2017 16:14:55
error 21-Dec-2017 16:14:55 Error: Cannot find module ‘etag’
error 21-Dec-2017 16:14:55 at Function.Module._resolveFilename (module.js:325:15)
error 21-Dec-2017 16:14:55 at Function.Module._load (module.js:276:25)
error 21-Dec-2017 16:14:55 at Module.require (module.js:353:17)
Please provide issue details here.
Steps to reproduce/test case
Please provide necessary steps for reproduction of this issue, or better the
reduced test case (without any external dependencies).
Please specify which version of Browsersync, node and npm you’re running
- Browsersync [ 2.20.0 ]
- Node [ 4.4.5 ]
- Npm [ 2.15.11 ]
Affected platforms
- linux
- windows
- OS X
- freebsd
- solaris
- other (please specify which)
Browsersync use-case
If CLI, please paste the entire command below
for all other use-cases, (gulp, grunt etc), please show us exactly how you’re using Browsersync
The text was updated successfully, but these errors were encountered:
Источник
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
EJSONPARSEnpm 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.parsenpm 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
Posted By: Anonymous
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
EJSONPARSEnpm 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.parsenpm 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
Solution
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
Answered By: Anonymous
Related Articles
- I was expecting segmentation fault or some kind of out of…
- How to use vue.js with gulp?
- npm install error in vue
- gulp dependent tasks — browserify and a pre-browserify task
- (generator-polymer) yo polymer fails, cannot find module…
- How to compile or convert sass / scss to css with node-sass…
- Using Gulp to Concatenate and Uglify files
- Aurelia and System.js production build
- Using SASS with Aurelia’s Skeleton Navigation project
- Polymer: two gulp errors at build time: ‘async completion’…
Disclaimer: This content is shared under creative common license cc-by-sa 3.0. It is generated from StackExchange Website Network.
index.min.js is missing from the latest version
Issue details
Error: ENOENT: no such file or directory, …….. node_modulesbrowser-syncclientdistindex.min.js
Same problem here… Reload/Stream functions suddenly stopped work.
Same issue here, after updating to v2.24.0
Same issue. Error log as follows:
Error: ENOENT: no such file or directory, open '/Users/.../node_modules/browser-sync/client/dist/index.min.js'
at Object.fs.openSync (fs.js:545:3)
at Object.fs.readFileSync (fs.js:451:33)
at /Users/.../node_modules/browser-sync/dist/snippet.js:87:29
at /Users/.../node_modules/browser-sync/dist/client.js:52:35
at Array.reduce (<anonymous>)
at processItems (/Users/.../node_modules/browser-sync/dist/client.js:47:10)
at /Users/.../node_modules/browser-sync/dist/client.js:80:22
at call (/Users/.../node_modules/connect/index.js:239:7)
at next (/Users/.../node_modules/connect/index.js:183:5)
at next (/Users/.../node_modules/connect/index.js:161:14)
I began to see this error message after upgrading npm to v6.0.0; even with browsersync v2.18.15
You are right @vinceshere I was looking through the node_modules for previous projects that I had been using browsersync with, and they were working fine because the contents for that folder were intact. The cause as far as I can tell is that the contents for the directory you mention are now gone.
To correct my previous comment: It has nothing to do with npm v6.0.0, tested old installs of browser-sync with npm v6 and they work fine
browser-sync/client/dist contents are missing in new installs of browser-sync, that is the cause for this error message. I just copied the missing files into the empty folder and now it’s working fine
Please change this issue’s title to something like:
«index.min.js is missing from the latest version»
Not trying to be a grammar nasty but at least it would be easier to understand if it were «does not» instead of «don’t».
HEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEELP!!!)))))
@dhffdh pin your version to the old one "browser-sync": "2.23.7",
.
@huochunpeng THANK YOU =)
Thanks all for the fast feedback
I had removed the compiled assets from the repo, with the aim of rebuilding them only when publishing — but I used an incorrect NPM lifecycle hook — oops!
It’s fixed now though browser-sync@2.24.1
❤️
@shakyShane I like the removal in general.
FYI, but it could create some trouble for some users (like contributors) who directly installs the package from git repo, if they use yarn or pnpm.
yarnpkg/yarn#5235
pnpm/pnpm#855
@shakyShane Hi, I think this issue might be revived again from the latest release v2.27.10. I ras running v2.27.9 in my projects and started to get this error recently.
@shakyShane Same for me. I started to see this problem (missing index.min.js) when upgrading to v2.27.10.
Same here in my new jHipster project with «browser-sync»: «2.27.9»,
I also experienced the same issue when using JHipster to create a new standalone app using browser-sync
version 2.27.9
. For now I have went back to pinning to an older version in the package.json
viz., "browser-sync": "2.24.1"
Hello guys,
- I ran into the exactly same problem when using JHipster as well, when in package.json : «browser-sync»: «2.27.9», and when run npm install first time (no node_modules exists), it will generate package-lock.json with this dependency of browser-sync-client
«browser-sync-client»: {
«version»: «2.27.10»,
«resolved»: «https://registry.npmjs.org/browser-sync-client/-/browser-sync-client-2.27.10.tgz»,
«integrity»: «sha512-KCFKA1YDj6cNul0VsA28apohtBsdk5Wv8T82ClOZPZMZWxPj4Ny5AUbrj9UlAb/k6pdxE5HABrWDhP9+cjt4HQ==»,
«dev»: true,
«requires»: {
«etag»: «1.8.1»,
«fresh»: «0.5.2»,
«mitt»: «^1.1.3»,
«rxjs»: «^5.5.6»,
«typescript»: «^4.6.2»
},
- And here comes the problem with missing index.min.js in browser-sync-client:2.27.10 . You guys can double check by download gz file from: https://registry.npmjs.org/browser-sync-client/-/browser-sync-client-2.27.10.tgz and see the problem. This is the full error log I got:
Error: Cannot find module ‘browser-sync-client/dist/index.min.js’
Require stack:
-myproject/node_modules/browser-sync/dist/snippet.js
-myproject/node_modules/browser-sync/dist/hooks.js
-myproject/node_modules/browser-sync/dist/browser-sync.js
-myproject/node_modules/browser-sync/dist/index.js
-myproject/node_modules/browser-sync-webpack-plugin/lib/BrowserSyncPlugin.js
-myproject/node_modules/browser-sync-webpack-plugin/index.js
-myproject/webpack/webpack.custom.js
-myproject/node_modules/@angular-builders/custom-webpack/dist/utils.js
-myproject/node_modules/@angular-builders/custom-webpack/dist/custom-webpack-builder.js
-myproject/node_modules/@angular-builders/custom-webpack/dist/transform-factories.js
-myproject/node_modules/@angular-builders/custom-webpack/dist/generic-browser-builder.js
-myproject/node_modules/@angular-builders/custom-webpack/dist/dev-server/index.js
-myproject/node_modules/@angular/cli/node_modules/@angular-devkit/architect/node/node-modules-architect-host.js
-myproject/node_modules/@angular/cli/node_modules/@angular-devkit/architect/node/index.js
-myproject/node_modules/@angular/cli/models/architect-command.js
-myproject/node_modules/@angular/cli/commands/serve-impl.js
-myproject/node_modules/@angular-devkit/schematics/tools/export-ref.js
-myproject/node_modules/@angular-devkit/schematics/tools/index.js
-myproject/node_modules/@angular/cli/utilities/json-schema.js
-myproject/node_modules/@angular/cli/models/command-runner.js
-myproject/node_modules/@angular/cli/lib/cli/index.js
-myproject/node_modules/@angular/cli/lib/init.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
at Function.resolve (internal/modules/cjs/helpers.js:98:19)
atmyproject/node_modules/browser-sync/dist/snippet.js:87:52
atmyproject/node_modules/browser-sync-client/index.js:59:39
at Array.reduce ()
at processItems myproject/node_modules/browser-sync-client/index.js:54:10)
atmyproject/node_modules/browser-sync-client/index.js:89:22
at call myproject/node_modules/connect/index.js:239:7)
at next myproject/node_modules/connect/index.js:183:5)
at next myproject/node_modules/connect/index.js:161:14)
- Note that with version browser-sync-client:2.27.9 , it was OK, no missing index.min.js , the package-lock.json should be like this:
«browser-sync-client»: {
«version»: «2.27.9»,
«resolved»: «https://registry.npmjs.org/browser-sync-client/-/browser-sync-client-2.27.9.tgz»,
«integrity»: «sha512-FHW8kydp7FXo6jnX3gXJCpHAHtWNLK0nx839nnK+boMfMI1n4KZd0+DmTxHBsHsF3OHud4V4jwoN8U5HExMIdQ==»,
«dev»: true,
«requires»: {
«etag»: «1.8.1»,
«fresh»: «0.5.2»,
«mitt»: «^1.1.3»,
«rxjs»: «^5.5.6»
},
-
How I quick fixed the problem: just same as @krmahadevan did, I explicitly put in my package.json the dependency: «browser-sync-client»: «2.27.9». I removed the node_modules folder, and I run the npm install again. Now the package-lock.json will have the browser-sync-client:2.2.7.9 again, and no more error in console :).
-
I believe the best fix must be to fix the release distribution of browser-sync-client-2.27.10.tgz itself.
In jhipster, instead of browser-sync-client@2.27.10 change it to browser-sync-client@2.27.9 by
- Delete package-lock.json
- install npm i browser-sync-client@2.27.9
- npm install
- check package.json to verify the update of browser-sync-client then try ./mvnw or npm start
I ran into this issue testing out a browser sync update. Since this issue was closed back 2018 and fixed does it make sense to reopen this thread or make a new one since a recent update in client caused the same issue?
Currently my workaround is to keep my pinned package.lock file for browser sync to the older version.
Здесь та же проблема … Функции перезагрузки / потоковой передачи внезапно перестали работать.
Та же проблема здесь после обновления до v2.24.0
Та же проблема. Журнал ошибок выглядит следующим образом:
Error: ENOENT: no such file or directory, open '/Users/.../node_modules/browser-sync/client/dist/index.min.js'
at Object.fs.openSync (fs.js:545:3)
at Object.fs.readFileSync (fs.js:451:33)
at /Users/.../node_modules/browser-sync/dist/snippet.js:87:29
at /Users/.../node_modules/browser-sync/dist/client.js:52:35
at Array.reduce (<anonymous>)
at processItems (/Users/.../node_modules/browser-sync/dist/client.js:47:10)
at /Users/.../node_modules/browser-sync/dist/client.js:80:22
at call (/Users/.../node_modules/connect/index.js:239:7)
at next (/Users/.../node_modules/connect/index.js:183:5)
at next (/Users/.../node_modules/connect/index.js:161:14)
Я начал видеть это сообщение об ошибке после обновления npm до v6.0.0 ; даже с Browsersync v2.18.15
Вы правы, @vinceshere. Я просматривал node_modules для предыдущих проектов, с которыми я использовал синхронизацию браузеров, и они работали нормально, потому что содержимое этой папки было неповрежденным. Насколько я могу судить, причина в том, что содержимое указанного вами каталога исчезло.
Чтобы исправить мой предыдущий комментарий: он не имеет ничего общего с npm v6.0.0, протестировал старые установки browser-sync с npm v6, и они отлично работают
Содержимое browser-sync / client / dist отсутствует в новых установках browser-sync, что является причиной этого сообщения об ошибке. Я просто скопировал недостающие файлы в пустую папку и теперь все работает нормально
Измените заголовок этого выпуска на что-то вроде:
«index.min.js отсутствует в последней версии»
Не пытаюсь навредить грамматике, но, по крайней мере, было бы легче понять, если бы было «не», а не «не надо».
HEEEEEEEEEEEEEEEEEEEEEEELP !!!)))))
@dhffdh закрепите вашу версию на старой "browser-sync": "2.23.7",
.
Спасибо всем за быстрый отзыв
Я удалил скомпилированные активы из репозитория с целью перестроить их только при публикации, но я использовал неправильный крючок жизненного цикла NPM — упс!
Теперь это исправлено, хотя [email protected]
❤️
When you are working in Node, you will sometimes encounter the error Cannot find module 'module-name'
with the error code MODULE_NOT_FOUND
.
The error looks like this:
internal/modules/cjs/loader.js:796
throw err;
^
Error: Cannot find module 'module'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:793:17)
at Function.Module._load (internal/modules/cjs/loader.js:686:27)
at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10)
at internal/main/run_main_module.js:17:11 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
In this post, we’ll learn how to resolve this error.
What is the problem?
The issue is that Node is unable to find the module that you are trying to import into your Node application.
The most common reason for this is that you simply haven’t installed the project’s dependencies yet.
The project’s dependencies are listed in the package.json
file at the root of the project.
The Solution
To fix the Cannot find module
error, simply install the missing modules using npm
.
To so, you can use the following command:
npm install
If you are using the yarn
package manager, you can use the following command:
yarn install
This will install the project’s dependencies into your project so that you can use them.
Sometimes, this might still not resolve it for you. In this case, you’ll want to just delete your node_modules
folder and lock file (package-lock.json
or yarn.lock
) and try again.
This is how you can delete the node_modules
folder and lock files:
rm -rf node_modules
rm package-lock.json
rm yarn.lock
Local files
If your module is not coming from a remote source, you are seeing the error because the path to the local file is not correct.
Try to confirm that the path pointing to the local module is correct and your error should be resolved.
Conclusion
The Cannot find module
error is a common error that usually happens when dependencies are not installed. Once you install your dependencies and ensure that the paths are correct, you can resolve the error and run your application successfully.
Hopefully, this resolved the issue for you.
Thanks for reading!
If you want to learn about web development, founding a start-up, bootstrapping a SaaS, and more, follow me on Twitter! You can also join the conversation over at our official Discord!
-
Support Us
-
Join
-
Share
-
Tweet
-
Share
Give feedback on this page!
JavaScript’s Node.js server supports module export and import in both ECMAScript modules and CommonJS format.
Sometimes, npm will throw an error saying Cannot find module
because of module import as shown below:
$ node index.js
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module 'axios'
Require stack:
- /n-app/index.js
at ... {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/n-app/index.js' ]
}
Here’s the content of the index.js
file:
var axios = require("axios");
The cannot find module error occurs because npm cannot find the module required by the index.js
file. In this case, the axios
module.
To resolve the error, you need to make sure that axios
is installed in the node_modules/
folder.
Please note that the node_modules/
folder must be located in the same directory as the index.js
file:
.
├── index.js
├── node_modules
├── package-lock.json
└── package.json
If you have run the npm install
command before, then it’s possible that the installation of the module is incomplete or corrupted.
Delete the node_modules/
folder using the rm -rf node_modules
command, then run npm install
again. That may fix the issue.
Finally, the same error can happen when you require()
a local .js
file that can’t be found.
Suppose you have a file named lib.js
placed in the same folder as the index.js
file:
.
├── index.js
└── lib.js
To import the file, you need to specify the correct path in the require()
function.
The following code:
var helper = require("lib.js");
Will produce the same error:
$ node index.js
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module 'lib.js'
Require stack:
- /n-app/index.js
at ... {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/n-app/index.js' ]
}
This is because the require()
function will always look inside the node_modules/
folder.
To let Node.js knows that you are importing a local file, use the absolute path as follows:
The ./
syntax means the root directory where you run the node
command. In this case, the folder where index.js
is located.
If you have a file one level down like this:
.
├── index.js
└── helpers
└── lib.js
Then you need to adjust the require()
path as shown below:
var helper = require("./helpers/lib.js");
The same also applies when you use the ES modules format as follows:
import helper from "./helpers/lib.mjs";
To conclude, the error “Cannot find module” happens when Node.js can’t find the module that a file is trying to import.
You can see the file and the module that’s causing the issue from the error output generated by Node itself.
And that’s how you resolve the npm cannot find module issue. Great work! 😉