0

I recently installed npm-windows-upgrade to upgrade to the latest version of npm. This was to get rid of an issue I was having where node modules would get installed but would often exceed the windows maximum path length due to all the nesting of dependencies.

After this procedure was performed, livereload.js was no longer being loaded into the browser and my gulp task was crashing I accessed the page URL. Node would end up spitting this to the console:

events.js:72 throw er; // Unhandled 'error' event ^ Error: ENOENT, open 'C:[project path]\node_modules\tiny-lr\node_modules\livereload-js\dist\livereload.js' Process terminated with code 8

What is the problem and how to resolve it?

tensai
  • 1,628
  • 3
  • 17
  • 22

1 Answers1

0

The issue here is that when installing npm-windows-upgrade to later versions of npm is that npm no longer installs packages as nested dependencies unless said package conflicts with another package version on the top level.

This means that the node_modules that are part of tiny-lr no longer exist in the subdirectory that tiny-lr expects them to be in when you specify them. This means that a means of communicating this change has to be established to the tiny-lr module.

luckily on instantiation of tiny-lr you can specify the path to the livereload.js file.

lrserver = require('tiny-lr')({ livereload: "node_modules/livereload-js/dist/livereload.js" }),

Note that the path is the relative path from where you gulpfile is being executed from.

tensai
  • 1,628
  • 3
  • 17
  • 22