gulp-community / gulp-less

A LESS plugin for Gulp
559 stars 116 forks source link

Last night gulp-less install started failing #308

Closed jmwolfe closed 4 years ago

jmwolfe commented 4 years ago

Hello,

yesterday, 2/9/2020 some time after 4pm gulp-less just started failing to build out on our CI/CD server.

I started getting this error:

D:\BuildAgent\work\TPP.CMGR.PMM2\ContentManager\ContentManager>gulp --tasks-simple D:\BuildAgent\work\TPP.CMGR.PMM2\ContentManager\ContentManager\node_modules\gulp-less\node_modules\accord\lib\adapter_base.js:105 throw new Error("'tried to require: " + this.supportedEngines + "'.\nNone found. Make sure one has been installed!"); ^

Error: 'tried to require: less'. None found. Make sure one has been installed! at Less.Adapter (D:\BuildAgent\work\TPP.CMGR.PMM2\ContentManager\ContentManager\node_modules\gulp-less\node_modules\accord\lib\adapter_base.js:105:15) at new Less (D:\BuildAgent\work\TPP.CMGR.PMM2\ContentManager\ContentManager\node_modules\gulp-less\node_modules\accord\lib\adapters\less\2.x - 3.x.js:17:41) at Object.exports.load (D:\BuildAgent\work\TPP.CMGR.PMM2\ContentManager\ContentManager\node_modules\gulp-less\node_modules\accord\lib\index.js:31:12) at Object. (D:\BuildAgent\work\TPP.CMGR.PMM2\ContentManager\ContentManager\node_modules\gulp-less\index.js:9:29) at Module._compile (internal/modules/cjs/loader.js:688:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10) at Module.load (internal/modules/cjs/loader.js:598:32) at tryModuleLoad (internal/modules/cjs/loader.js:537:12) at Function.Module._load (internal/modules/cjs/loader.js:529:3) at Module.require (internal/modules/cjs/loader.js:636:17)`

here's my package.json:

{
  "version": "1.0.0",
  "name": "content.manager",
  "private": true,
   "devDependencies": {
   "gulp": "4.0.0",
   "gulp-less": "^4.0.1",
   "gulp-sourcemaps": "2.6.4"
  }
}

and my gulpfile.js:

/// <binding AfterBuild='less' />
/*
This file is the main entry point for defining Gulp tasks and using Gulp plugins.
Click here to learn more. https://go.microsoft.com/fwlink/?LinkId=518007
*/

var gulp = require("gulp"),
    fs = require("fs"),
    less = require("gulp-less"),
    sourcemaps = require('gulp-sourcemaps');

gulp.task("less", function (done) {
    return gulp.src('./Content/Site.less')
        .pipe(sourcemaps.init())
        .pipe(less())
        .pipe(sourcemaps.write('.'))
        .pipe(gulp.dest('Content'));
    done();
});

gulp.task("watch", function () {
    gulp.watch('Content/*.less', gulp.series('less'));
});

gulp.task("default", function (done) {
    gulp.series("watch");
    done();
}); 
yocontra commented 4 years ago

Your package manager is messing up somehow, are you using npm or yarn or something else? The error message is that it can't find the less module, but you can see here https://github.com/gulp-community/gulp-less/blob/master/package.json#L25 that it is listed as a dependency of this package. Check your install flow on CI and make sure something isn't messed up - if you are using lockfiles you should regenerate them.

Also - you can remove the done() callback completely from your example code.

Closing this since it isn't related to this module.

JBatCHECK24 commented 4 years ago

Hi there,

we had the same problems on our side. Problem comes up with less package 3.11.0 which is only some hours old. Fixed my deployment by installing less 3.10.3 after npm install. So I'm able to run gulp again. Hoping for a fix by gulp-less :)

Bye

yocontra commented 4 years ago

That is interesting... can you let me know if clearing your lockfiles helps? I just looked through accord and this package and don't see anything that would limit it to 3.10.3

jmwolfe commented 4 years ago

Wow guys thanks for replies. I was about to disable LESS and just commit my last known good Site.css. I mean just about to commit it.

I am using npm. using Restore Files via Visual Studio which runs: PATH=.\node_modules.bin;C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Microsoft\VisualStudio\NodeJs\win-x64;C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Microsoft\VisualStudio\NodeJs;C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Web\External;%PATH%;C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\cmd;C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\mingw32\bin "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Microsoft\VisualStudio\NodeJs\npm.CMD" install npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.11 (node_modules\fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.11: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"ia32"}) audited 6884 packages in 6.165s found 0 vulnerabilities PATH=.\node_modules.bin;C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Microsoft\VisualStudio\NodeJs\win-x64;C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Microsoft\VisualStudio\NodeJs;C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Web\External;%PATH%;C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\cmd;C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\mingw32\bin "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Microsoft\VisualStudio\NodeJs\npm.CMD" install npm notice created a lockfile as package-lock.json. You should commit this file. npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.11 (node_modules\fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.11: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"ia32"}) audited 6884 packages in 6.992s found 0 vulnerabilities

As you see it is creating a .lock file.

I deleted the .lock file... error still happens when I run gulp. are there other .lock files i should look for?

BTW nothing changed on CI flow. Only change was a tweak to some HTML - nothing to do with less. I rolled that back to check if it could be a problem but no.

jmwolfe commented 4 years ago

@JBatCHECK24 - I misread your original comment. I did an install of less@3.10.3 and that fixed the issue. THANK YOU. I will add it into my gulp.js file until this issue is resolved. Shall we reopen? :)

JBatCHECK24 commented 4 years ago

@contra clearing lockfile helps nothing. Npm installs less latest on gulp-less install. So pinning is at the moment the solution. The problem is also reported at less package.

yocontra commented 4 years ago

Linking for reference: https://github.com/less/less.js/issues/3470

For now you can put this in your package.json and it should hold you over until less fixes it:

"resolutions": {
  "less": "3.10.3"
}
jmwolfe commented 4 years ago

That fixes it locally but for some reason CI process is still choking with the same message.

I'm running this command from CI:

call npm install --no-optional 

do i need other flags? Doesn't seem to notice my "resolutions" section. I have also tried "dependencies" which is what install less@3.10.3 did.

I can also add another command after install to install less@3.10.3.

jmwolfe commented 4 years ago

I just learned that the "resolutions" json element was for yarn, which I don't use, and npm doesn't seem to have an easy way to lock the child dependencies, at least according to https://stackoverflow.com/questions/52416312/npm-equivalent-of-yarn-resolutions .

What is odd is that at the command line, it seems using "dependencies" worked, but in my CI it does not. Most of my dependencies are devDependencies because it's for less, which is only used at build time. something about the version of npm that VS is running on our CI server doesn't seem to get the pinning.

I ended up adding another npm install less@3.10.3 after i do my main npm install --no-optional. That seems to have done it.

JBatCHECK24 commented 4 years ago

@jmwolfe I've made exactly the same experiences with npm and ended up also with adding this additional command afterwards.

jmwolfe commented 4 years ago

@JBatCHECK24 - Ithought it worked locally. But it is not working in CI. I had to resort adding an additional line to check out less@3.10.3 after the main npm install.

yocontra commented 4 years ago

I'll reopen this for discoverability so other people can find it. I looked through the less changelog and nothing stood out, so maybe they just published a bad version or something.

JBatCHECK24 commented 4 years ago

Fixed with https://github.com/less/less.js/commits/v3.11.1. So from my side everything is okay and no additional command is needed anymore.

yocontra commented 4 years ago

For anyone who hasn't figured it out - just clear your lockfiles and run npm install to get the new less version.