gulp dev cant be run because of mistake - node.js

I run npm install in the project's root and then when I try to run gulp de, I get the following mistake:
$ gulp dev
module.js:442
throw err;
^
Error: Cannot find module './lib/public/public-utils'
at Function.Module._resolveFilename (module.js:440:15)
at Function.Module._load (module.js:388:25)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\ente\node_modules\browser-sync\index.js:9:21)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\ente\gulpfile.js:27:21)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Liftoff.handleArguments (C:\Users\Man\AppData\Roaming\npm\node_modules\gulp\bin\gulp.js:116:3)
at Liftoff.<anonymous> (C:\Users\Man\AppData\Roaming\npm\node_modules\gulp\node_modules\liftoff\index.js :193:16)
at module.exports (C:\Users\Man\AppData\Roaming\npm\node_modules\gulp\node_modules\flagged- respawn\index.js:17:3)
at Liftoff.<anonymous> (C:\Users\Man\AppData\Roaming\npm\node_modules\gulp\node_modules\liftoff\index.js:185:9)
at C:\Users\Man\AppData\Roaming\npm\node_modules\gulp\node_modules\liftoff\index.js: 159:9
at C:\Users\Man\AppData\Roaming\npm\node_modules\gulp\node_modules\v8flags\index.js:108:14
at C:\Users\Man\AppData\Roaming\npm\node_modules\gulp\node_modules\v8flags\index.js:36:12
at C:\Users\Man\AppData\Roaming\npm\node_modules\gulp\node_modules\v8flags\index.js:47:7
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)
at Module.runMain (module.js:577:11)
at run (bootstrap_node.js:352:7)
at startup (bootstrap_node.js:144:9)
at bootstrap_node.js:467:3
the gulp file
i tried different things, like to go to an older node, to the latest one, reinstalled node, npm and gulp billions of times, but it didnt help.
What can it be and how to fix it?

The error seems to happen when you require the browser-sync module in your gulpfile. The module doesn't find one of it's own components ./lib/public/public-utils and can't start.
I'd first check in your node_modules directory to see what's going on with browser-sync.
It's usually a corrupted install of the module.
Make sure that in your package.json you have browser-sync listed with the most up-to-date version (2.13.0) and to get a fresh install delete your node_modules directory, npm cache clean
and run npm install again.

Related

Cannot find module './driver'

when i run my project in nodejs i get this error:
Error: Cannot find module './driver'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:831:15)
at Function.Module._load (internal/modules/cjs/loader.js:687:27)
at Module.require (internal/modules/cjs/loader.js:903:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Module._compile (internal/modules/cjs/loader.js:1015:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10)
at Module.load (internal/modules/cjs/loader.js:879:32)
at Function.Module._load (internal/modules/cjs/loader.js:724:14)
at Module.require (internal/modules/cjs/loader.js:903:19)
please someone can help me!
Probably this is npm related problem. Try to delete node_modules and package-lock.json and run npm install.
If above solution doesn't work for you, try to use yarn rather than npm, which I did when I had this problem.

What is module.js 540 throw error?

Just installing node/npm first time, Linux Fedora: I've followed all the instructions and tried every fix I can find on google.
Whenever I try to run npm install or npm test I get this:
module.js:540
throw err;
^
Error: Cannot find module 'npmlog'
at Function.Module._resolveFilename (module.js:538:15)
at Function.Module._load (module.js:468:25)
at Module.require (module.js:587:17)
at require (internal/module.js:11:18)
at /usr/lib/node_modules/npm/bin/npm-cli.js:22:13
at Object.<anonymous> (/usr/lib/node_modules/npm/bin/npm-cli.js:92:3)
at Module._compile (module.js:643:30)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
It was a bug and it has already been fixed in Node v5.4.1. Now it's working as usual.

Node.js Cannot find module './internal/streams/stream'

I get an error when I want to use gulp for deployment.
Error: Cannot find module './internal/streams/stream'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/var/www/pomelo/themes/pomelo/assets/js/node_modules/gulp-replace/node_modules/readable-stream/lib/_stream_readable.js:50:14)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
So I use npm install readable-stream, but this is still the error.
Why? How can I fix it?
Try this:
rm -rf node_modules
npm install
What worked for me is to delete the package-lock.json file and the node_modules folder, then run npm install.
It's a core node lib. Try first,
npm cache clean
If not work, reinstall node

Error: Cannot find module 'internal/linkedlist' in WebStorm

I have a script that runs fine when I run it in terminal with node, but using WebStorm I can't properly run it as it crashes on a dependency require line.
I've attempted to npm install internal/linkedList, I've also attempted to npm cache clean (as recommended in another post).
The full stack trace is:
Error: Cannot find module 'internal/linkedlist'
at Function.Module._resolveFilename (module.js:485:15)
at Function.Module._load (module.js:437:25)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/harshagoli/Library/Preferences/WebStorm2017.2/javascript/nodejs/8.1.4/core-modules/timers.js:26:11)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)

NodeJS Error: Module version mismatch. Expected 48, got 46

After I upgraded NodeJS and NPM to 6.2.0 and 3.9.3, when I run hexo d -g command to update my blog, I get the following error:
Error: Module version mismatch. Expected 48, got 46.
at Error (native)
at Object.Module._extensions..node (module.js:568:18)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/local/lib/node_modules/hexo-cli/node_modules/dtrace-provider/dtrace-provider.js:17:23)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/local/lib/node_modules/hexo-cli/node_modules/bunyan/lib/bunyan.js:79:18)
{ Error: Cannot find module './build/default/DTraceProviderBindings'
at Function.Module._resolveFilename (module.js:440:15)
at Function.Module._load (module.js:388:25)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/local/lib/node_modules/hexo-cli/node_modules/dtrace-provider/dtrace-provider.js:17:23)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/local/lib/node_modules/hexo-cli/node_modules/bunyan/lib/bunyan.js:79:18)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32) code: 'MODULE_NOT_FOUND' }
{ Error: Cannot find module './build/Debug/DTraceProviderBindings'
at Function.Module._resolveFilename (module.js:440:15)
at Function.Module._load (module.js:388:25)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/local/lib/node_modules/hexo-cli/node_modules/dtrace-provider/dtrace-provider.js:17:23)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/local/lib/node_modules/hexo-cli/node_modules/bunyan/lib/bunyan.js:79:18)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32) code: 'MODULE_NOT_FOUND' }
(node) v8::ObjectTemplate::Set() with non-primitive values is deprecated
(node) and will stop working in the next major release.
I thought maybe Node.js is upgraded and node_modules should be reinstalled.
I tried rm -rf node_modules && npm install, but it doesn't work. I also tried sudo npm i -g npm then npm install hexo --no-optional --save, which doesn't work neither.
Any advice would be most appreciated.
Actually, after upgrading node, your installed packages kept compiled against the older version, and they need to be rebuilt. No need to delete node_modules, or running npm update.
Just run:
npm rebuild
Hexo doesn't seem to work with lastest version of node which is 6.2.0. You should use node-v4.4.5 (LTS) for a while, which is recommended version for most users.
It looks like hexo is a globally installed package, but you only reinstalled it locally. Try to reinstall it globally:
npm install hexo -g
Maybe your Global installation files has not been update, please try to update your hexo-cli with command below:
sudo npm install -g hexo-cli
which solved my problem.

Resources