Error: Cannot find module 'gulp-uglifyjs' with "gulp watch - gulp

I´m in my project folder on my terminal, and:
if I extecute:
gulp -v
I get:
[15:47:15] CLI version 3.9.0
[15:47:15] Local version 3.9.0
if I excute:
gulp watch
I get:
Error: Cannot find module 'gulp-uglifyjs'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:289:25)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object.<anonymous> (/Applications/XAMPP/xamppfiles/htdocs/last/gulpfile.js:3:14)
at Module._compile (module.js:425:26)
at Object.Module._extensions..js (module.js:432:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:313:12)
at Module.require (module.js:366:17)
at require (module.js:385:17)
Then, I search in the gulpfile.js 3:14 and I see this:
var uglify = require('gulp-uglifyjs');
I was read about this, a lot people say "oh, do npm install", I do, and after make npm -v I get this:
3.3.12
I was trying with a lot commands, but I dont know what happen. Maybe gulpfile.js?
Maybe I forgot a dependencie?

Maybe I forgot a dependencie?
Yes maybe local installation will resolve you problem. Run next command in you project:
npm install --save-dev gulp-uglify

Try to replace
require('gulp-uglifyjs');
with
require('gulp-uglify');
see also https://www.npmjs.com/package/gulp-uglify

Related

How do I fix tailwindcss-cli from throwing TypeError: Object.fromEntries is not a function?

I've been following Tailwind's tutorials and when. I get to the part of the tutorial where they ask me to run npx tailwindcss-cli build css/tailwind.css -o build/tailwind.css, I get the following error. How do I solve this?
(node:5568) ExperimentalWarning: The fs.promises API is experimental
/Users/USERNAME-REDACTED/.npm/_npx/8bcfa250e55e6bf5/node_modules/tailwindcss/lib/jit/corePlugins.js:242
...Object.fromEntries(Object.entries(corePlugins).map(([pluginName, plugin]) => {
^
TypeError: Object.fromEntries is not a function
at Object.<anonymous> (/Users/USERNAME-REDACTED/.npm/_npx/8bcfa250e55e6bf5/node_modules/tailwindcss/lib/jit/corePlugins.js:242:13)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/Users/USERNAME-REDACTED/.npm/_npx/8bcfa250e55e6bf5/node_modules/tailwindcss/lib/jit/lib/setupContextUtils.js:36:43)
at Module._compile (internal/modules/cjs/loader.js:778:30)
I've tried deleting npm, updating npm, removing my package-lock and node modules and restarting, and adding -i. all to no prevail. As is made apparent from the youtube series I linked, I'm just learning tailwind, so I'm sure it's a super stupid mistake.
The issue originated from your node version.
Please try this:
sudo npm i -g n
Than inside your project folder
n latest
after that close your current terminal, since it will remember the old node location, open a new one and it should be fixed.
If you don't want the overhead of nvm then you can just download a binary release of nodejs, eg:
mkdir -p ~/opt/src
cd ~/opt/src
wget https://nodejs.org/download/release/v14.17.0/node-v14.17.0-linux-x64.tar.xz
cd ~/opt tar xf src/node-v14.17.0-linux-x64.tar.xz --strip 1
To use it interactively first run:
export PATH=$HOME/opt/bin:$PATH
Source:https://community.opalstack.com/d/636-install-node-and-npm-without-having-to-sudo

Gulp watch task was working fine, but is now generating an error when I try to start it

I'm working on a course project using gulp. Gulp has been working fine for weeks, but today I sat down at my computer to continue the course and am getting an error when I try and start my gulp watch task. Again, this has been working fine for weeks prior to today.
When I attempt to run gulp watch I get the following error:
module.js:471
throw err;
^
Error: Cannot find module 'lodash._basevalues'
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> (/Users/rockypruitt/Google Drive/Web Design and
Development/Learning to Code/Udemy-Git a web developer job - Brad
Schiff/Sites/travel-site/node_modules/lodash.template/index.js:11:18)
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)
Any assistance will be appreciated.
Rocky you should try with Remove node_modules folder and run npm install again.

Laravel 5.3 passport authentication: unable to compile view components with gulp

I've been following the laravel's api token-based authentication using passport. I followed all the steps in this screen cast by Taylor Otwell himself. To publish the passport Vue components, I ran the command:
php artisan vendor:publish --tag=passport-components
and the components where rightly published in the resources/assets/js/components directory.
Next,I registered the some components in resources/assets/js/app.js file and here's the result:
require('./bootstrap');
Vue.component('example', require('./components/Example.vue'));
Vue.component(
'passport-clients',
require('./components/passport/Clients.vue')
);
Vue.component(
'passport-authorized-clients',
require('./components/passport/AuthorizedClients.vue')
);
Vue.component(
'passport-personal-access-tokens',
require('./components/passport/PersonalAccessTokens.vue')
);
const app = new Vue({
el: '#app'
});
I ran the command gulp but gulp wasn't recognized so I installed with the following two commands:
npm install --global gulp-cli
npm install --save-dev gulp
Here is my gulpfile.js file by the way (at the root of my project):
const elixir = require('laravel-elixir');
require('laravel-elixir-vue-2');
var gulp = require('gulp');
elixir(function(mix){
mix.sass('app.scss')
.webpack('app.js');
});
next a pasted the following components in the home.blade.php view file after logging in:
<passport-clients></passport-clients>
<passport-authorized-clients></passport-authorized-clients>
<passport-personal-access-tokens></passport-personal-access-tokens>
I now ran the command gulp in the root of my application and got the following error:
> Error: Cannot find module 'laravel-elixir'
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> (/home/awa/Desktop/laravel53/gulpfile.js:1:78)
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)
I may be making some silly mistaker here but I just can't get my way out of it. I am new to Laravel. I'll appreciate any help.
Thanks
It looks like you don't have Laravel Elixir installed. It is is not automatically installed with laravel, you need to run:
npm install
from the root of your project, which will download laravel elixir and all it's dependencies.

polyserve is not working on local development environment

I am trying to launch polyserve on my local development environment but it is not working. thought it might be due to node.js updated node but still getting this error.
/usr/local/lib/node_modules/polyserve/bin/polyserve:14
const resolve = require('resolve'); ^^^^^ SyntaxError: Use of const in
strict mode.
at Module._compile (module.js:439:25)
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 Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3
According to my copy of polyserv, its package.json file says it needs the resolve module
https://www.npmjs.com/package/resolve
Your error is that it can't find it.
Is polyserve installed locally - run npm install

Issues with ionic: Error: Cannot find module 'gulp-util'

I've got some issues with trying to run gulp with Ionic.
The error message that pops up is this:
Error: Cannot find module 'gulp-util'
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. (/Users/emilymacleod/Desktop/myApp/gulpfile.js:2:13)
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)
I tried installing sass and gulp locally in the myApp folder as well as globally and no dice.
Thoughts?
Kind of a long shot, but gulp-util is a separated module. You should install it locally:
npm install gulp gulp-util --save-dev
and require it in your code:
var gutil = require('gulp-util');
I'm having the problem of cannot find gulp-util even after doing the procedure at the end of this. I can see it's added to the modules and the package.json, but that require statement seems to have an error. It doesn't seem to be working.
The PROCEDURE
npm install gulp gulp-util --save-dev
and require it in your code:
var gutil = require('gulp-util');
I had similar issue with gulp-sass. Error message was:
Uh oh! Looks like you're missing a module in your gulpfile:
Cannot find module 'gulp-sass'
Do you need to run npm install?
Resolved by executing the following:
npm -g install npm
npm install gulp-sass
Hope this help.