gulp-community / gulp-less

A LESS plugin for Gulp
559 stars 116 forks source link

Error: Cannot find module 'less' #322

Open MaxAlekseyev opened 1 year ago

MaxAlekseyev commented 1 year ago

gulp less --luma - ok gulp exec --isb - ok

but gulp less --isb failed

[19:48:18] Using gulpfile /var/www/domains/isb.wsl/gulpfile.js
[19:48:18] Starting 'less'...
Running gulp task LESS compilation for 1 theme(s):
isb
[19:48:18] 'less' errored after 78 ms
[19:48:18] Error: Cannot find module 'less'
Require stack:
- /var/www/domains/isb.wsl/node_modules/accord/lib/index.js
- /var/www/domains/isb.wsl/node_modules/gulp-less/index.js
- /var/www/domains/isb.wsl/node_modules/gulp-load-plugins/index.js
- /var/www/domains/isb.wsl/dev/tools/gulp/tasks/less.js
- /var/www/domains/isb.wsl/node_modules/require-dir/index.js
- /var/www/domains/isb.wsl/gulpfile.js
- /usr/local/lib/node_modules/gulp-cli/lib/shared/require-or-import.js
- /usr/local/lib/node_modules/gulp-cli/lib/versioned/^4.0.0/index.js
- /usr/local/lib/node_modules/gulp-cli/index.js
- /usr/local/lib/node_modules/gulp-cli/bin/gulp.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1090:15)
    at Function.resolve (node:internal/modules/helpers:125:19)
    at resolve_engine_path (/var/www/domains/isb.wsl/node_modules/accord/lib/index.js:65:18)
    at exports.load (/var/www/domains/isb.wsl/node_modules/accord/lib/index.js:25:19)
    at Object.<anonymous> (/var/www/domains/isb.wsl/node_modules/gulp-less/index.js:9:29)
    at Module._compile (node:internal/modules/cjs/loader:1275:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1329:10)
    at Module.load (node:internal/modules/cjs/loader:1133:32)
    at Module._load (node:internal/modules/cjs/loader:972:12)
    at Module.require (node:internal/modules/cjs/loader:1157:19)
MaxAlekseyev commented 1 year ago

Ubuntu 20.04 on WSL2

 gulp -v
CLI version: 2.3.0
Local version: 4.0.2
fzxen commented 1 month ago

I found v5 already fixed this error.

I encountered the same error with pnpm.

Gulp-less use accord.load to load less instead of require. However, accord.load doesn't change require context. image

maybe need specify path to load like this:

accord.load('less', __dirname);