Please advise i want to minify the .css files of my project with gulp so i have written the below task in my gulp.js file as shown below but still upon execution i am getting the error , please advise how to fix the below error
below is the code that I have written is
var gulp = require('gulp');
var minifyCss = require("gulp-minify-css");
gulp.task('minify-css', function () {
gulp.src('C:\\Softwares\\Spring4MVCAngularJSExample\\target\\Spring4MVCAngularJSExample\\static\\css\\*.css') // path to your file
.pipe(minifyCss())
.pipe(gulp.dest('C:\\Softwares\\Spring4MVCAngularJSExample\\target\\Spring4MVCAngularJSExample\\static\\cssoutput'));
});
below is the error i am getting upon execution
C:\Softwares\Spring4MVCAngularJSExample>gulp minify-css
module.js:471
throw err;
^
Error: Cannot find module 'gulp-minify-css'
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> (C:\Softwares\Spring4MVCAngularJSExample\gulpfile.js:10:13)
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)
It appears that it cannot locate the module. Have you run npm install gulp-minify-css --save-dev?
You may want to try re-installing your local packages / dependencies:
rm -rf node_modules/
npm install
Related
I'm using laravel elixir and gulp to compile my sass files. but when i write gulp in termial I get this error.
fs.js:27
const { Math, Object } = primordials;
^
ReferenceError: primordials is not defined
at fs.js:27:26
at req_ (/home/user/Videos/projetct-folder/project/node_modules/natives/index.js:143:24)
at Object.req [as require] (/home/user/Videos/projetct-folder/projetct/node_modules/natives/index.js:55:10)
at Object.<anonymous> (/home/user/Videos/projetct-folder/projetct/node_modules/laravel-elixir-livereload/node_modules/graceful-fs/fs.js:1:37)
at Module._compile (internal/modules/cjs/loader.js:774:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:785:10)
at Module.load (internal/modules/cjs/loader.js:641:32)
at Function.Module._load (internal/modules/cjs/loader.js:556:12)
at Module.require (internal/modules/cjs/loader.js:681:19)
at require (internal/modules/cjs/helpers.js:16:16)
Node version: 12.4.0
gulp CLI version: 2.2.0
gulp Local version: 4.0.2
gulpfile.js:
var elixir = require('laravel-elixir');
require('laravel-elixir-livereload');
elixir.config.assetsPath = 'themes/project/assets/';
elixir.config.publicPath = 'themes/project/assets/compiled/';
elixir(function(mix){
mix.sass('agency.scss');
mix.scripts([
'jqBootstrapValidation.js',
'agency.js',
'contact_me.js',
'recherche.js'
]);
mix.livereload([
'themes/project/assets/compiled/css/agency.css',
'themes/project/**/*.htm',
'themes/project/assets/compiled/js/*.js'
])
})
Judging by this bug report for Gulp, it's possible that one of the dependencies is using Gulp 3
one of the packages in your project is likely to be requiring gulp 3. If you inspect your package-lock.json which contains the list of installed packages, you should be able to sort it out.
It specifically mentions the graceful-fs module.
Today I tried to gulp a task inside my web application project folder on Tomcat8. I got a source code for a web app and I am trying to customize it.
I know there are several explanations about the errors I am going to show you, but it's always about switching from V3.9.1 to V4.0.2 and from V4.0.2 to V3.9.1 my gulp version. And I get a different problem on both :D
V3.9.1 Gulp:
C:\Users\Administrator\Documents\Source code for Apache\pa-downtime-uApp-master>gulp
fs.js:27
const { Math, Object } = primordials;
^
ReferenceError: primordials is not defined
at fs.js:27:26
at req_ (C:\Users\Administrator\Documents\Source code for Apache\pa-downtime-uApp-master\node_modules\natives\index.js:143:24)
at Object.req [as require] (C:\Users\Administrator\Documents\Source code for Apache\pa-downtime-uApp-master\node_modules\natives\index.js:55:10)
at Object.<anonymous> (C:\Users\Administrator\Documents\Source code for Apache\pa-downtime-uApp-master\node_modules\vinyl-fs\node_modules\graceful-fs\fs.js:1:37)
at Module._compile (internal/modules/cjs/loader.js:774:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:785:10)
at Module.load (internal/modules/cjs/loader.js:641:32)
at Function.Module._load (internal/modules/cjs/loader.js:556:12)
at Module.require (internal/modules/cjs/loader.js:681:19)
at require (internal/modules/cjs/helpers.js:16:16)
C:\Users\Administrator\Documents\Source code for Apache\pa-downtime-uApp-master>gulp -v
CLI version: 2.2.0
Local version: 3.9.1
V4.0.2 Gulp
AssertionError [ERR_ASSERTION]: Task function must be specified
at Gulp.set [as _setTask] (C:\Users\Administrator\Documents\Source code for Apache\pa-downtime-uApp-master\node_modules\undertaker\lib\set-task.js:10:3)
at Gulp.task (C:\Users\Administrator\Documents\Source code for Apache\pa-downtime-uApp-master\node_modules\undertaker\lib\task.js:13:8)
at Object.<anonymous> (C:\Users\Administrator\Documents\Source code for Apache\pa-downtime-uApp-master\gulpfile.js:18:6)
at Module._compile (internal/modules/cjs/loader.js:774:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:785:10)
at Module.load (internal/modules/cjs/loader.js:641:32)
at Function.Module._load (internal/modules/cjs/loader.js:556:12)
at Module.require (internal/modules/cjs/loader.js:681:19)
at require (internal/modules/cjs/helpers.js:16:16)
at execute (C:\Users\Administrator\AppData\Roaming\npm\node_modules\gulp-cli\lib\versioned\^4.0.0\index.js:36:18) {
generatedMessage: false,
code: 'ERR_ASSERTION',
actual: false,
expected: true,
operator: '=='
}
Task script
I was also wondering why in my task scripts there is no task name … I would like to try my commands with a task name after "gulp". When I check on other task files there is always a task name:
'use strict';
const gulp = require('gulp'),
war = require('gulp-war'),
zip = require('gulp-zip'),`enter code here`
path = require('path');
module.exports = function (gulp) {
return function () {
return gulp.src('dist/bundled/**')
.pipe(war({
welcome: 'index.html',
displayName: 'downtime-app',
}))
.pipe(zip('downtime-app.war'))
.pipe(gulp.dest('dist/'));
};
};
Sorry if I am saying any blunders, I am a total beginner and didn't even know what was HTML 1 week ago … :)
If you are using gulp 3.. and node 12+ => it will give the error.
Uninstall it and use node 11.. with gulp 3..
Ok, when I replace all my tasks by a single and basic one, the gulp 4.0.2V works well:
C:\Users\Administrator\Documents\Source code test\Source code test\Source code for Apache\pa-downtime-uApp-master>gulp bacon
[14:46:12] Using gulpfile ~\Documents\Source code test\Source code test\Source code for Apache\pa-downtime-uApp-master\gulpfile.js
[14:46:12] Starting 'bacon'...
miam miam
[14:46:12] The following tasks did not complete: bacon
[14:46:12] Did you forget to signal async completion?
So I think the problem remains in the dependencies between the several tasks or, in the bonds between the gulpfile.js and the task folder that was made by my web application creator.
Finally I found the task names in the gulpfile.js but even using them doesn't work.
I have installed gulp-run-command as follows:
npm install gulp-run-command
I'm running a series of gulp tasks. All the others work, except this one. Here's the task where I'm running gulp-run-command:
var gulp = require('gulp');
var run = require('gulp-run-command');
gulp.task('testTask', run('testString'));
It is directly from the basic usage of gulp-run-command as shown here:
https://www.npmjs.com/package/gulp-run-command#usage
I get the following error as I run gulp:
TypeError: run is not a function
at Object.<anonymous> (c:\mypath\gulp\tasks\common\initLocalJsonSe
rver.js:6:23)
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)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at requireDir (c:\mypath\node_modules\require-dir\index.js:123:33)
at requireDir (c:\mypath\node_modules\require-dir\index.js:76:33)
What's wrong here?
Ok, it worked as I added .default at the end of the line: var run = require('gulp-run-command');
So, like this:
var run = require('gulp-run-command').default
I've tried to install hello world application with this command:
gulp app:hello
I'm getting this error message:
module.js:338
throw err;
^
Error: Cannot find module 'C:\Users\name\AppData\Roaming\npm\node_modules
\gulp\node_modules\v8flags\3.28.73.flags.json'
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> (C:\Users\name\AppData\Roaming\npm\node_modules
\gulp\bin\gulp.js:25:22)
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 Function.Module.runMain (module.js:501:10)
Probably you have old version of Gulp.
Try to reinstall with npm install --global gulp.
I'm sure I'm doing something stupid, but I can't get node-fnoc to work. I have a directory with a simple package.json in it, I have a /config/ directory in that directory with a simple JSON file in it. And, I'm basically just trying to do what they have in their example.
var fnoc = require('fnoc');
fnoc(function(err, configs){
console.log(configs);
});
and this is what I'm getting:
fnoc(function(err, configs){
^
TypeError: object is not a function
at Object.<anonymous> (/opt/backups/readconfig.js:3:1)
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 Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:901:3
Any ideas?
The document on github is for version 0.2.2
You need to install fnoc#0.2.2
npm install fnoc#0.2.2
Run your js
node your.js
Output:
{ package:
{ name: 'asdf',
dependencies:
{ express: '*',
jade: '*',
Version is in the changelog file:
https://github.com/jprichardson/node-fnoc/blob/master/CHANGELOG.md