TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received null
See original GitHub issueNameless is Here!
So I’m trying to make a gulp
task which optimises images (obviously). Here are my files:
gulpfile.esm.js
import gulp from 'gulp';
import images from './gulp/tasks/images.js';
import config from './gulp/config.js';
const build = () => gulp.series(
gulp.parallel(
images.build
)
);
const watch = () => gulp.series(
build,
gulp.parallel(
images.watch
)
);
let defaultTask;
if (config.env() === 'prod') {
defaultTask = build;
} else {
defaultTask = watch;
};
export default defaultTask;
./gulp/tasks/images.js
import gulp from 'gulp';
import plumber from 'gulp-plumber';
import changed from 'gulp-changed';
import gulpIf from 'gulp-if';
import imagemin from 'gulp-imagemin';
import pngquant from 'imagemin-pngquant';
import config from '../config.js';
const build = () => (
gulp.src(`${config.source.images}/**/*`)
.pipe(plumber())
.pipe(changed(config.build.images))
.pipe(gulpIf(config.env() === 'prod', imagemin([
pngquant({ quality: [ 0.8, 0.9 ] }),
imagemin.mozjpeg({ quality: 80 }),
imagemin.svgo()
])))
.pipe(gulp.dest(config.build.images))
);
const watch = () => gulp.watch(`${config.source.images}/**/*`, build);
export default { watch, build };
The error I get:
[21:14:04] Requiring external module esm
node_modules/gulp-imagemin/index.js:1
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received null
at new NodeError (node:internal/errors:371:5)
at validateString (node:internal/validators:119:11)
at Object.basename (node:path:1309:5)
at Error.<anonymous> (node:internal/errors:1450:55)
at getMessage (node:internal/errors:421:12)
at new NodeError (node:internal/errors:348:21)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1128:19) {
code: 'ERR_INVALID_ARG_TYPE'
- NodeJS version: 16.6.2
gulp
version: 4.0.2esm
version: 3.2.25gulp-changed
version: 4.0.3gulp-if
version: 3.0.0gulp-imagemin
version: 8.0.0,gulp-plumber
version: 1.2.1imagemin-pngquant
version: 9.0.2
Any help is appreciated! Sorry for my terrible english.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:8 (1 by maintainers)
Top Results From Across the Web
The "path" argument must be of type string ... - Stack Overflow
I'm working on a project in React and ran into a problem that has me stumped. Whenever I run yarn start I get...
Read more >[Fix] TypeError [ERR_INVALID_ARG_TYPE]: The “path ...
Have you run into the error “TypeError [ERR_INVALID_ARG_TYPE]: The “path” argument must be of type string. Received undefined”? In this story I'll go...
Read more >Why I got TypeError [ERR_INVALID_ARG_TYPE]: The "path ...
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received null at new NodeError (node:internal/errors:278:15) ...
Read more >The path argument must be of type string - Reactgo
In this tutorial, we are going to learn about how to fix the TypeError [ERR_INVALID_ARG_TYPE]: The “path” argument must be of type string....
Read more >npm err! code err_invalid_arg_type npm err! the path ...
TypeError [ERRINVALIDARGTYPE]: The "path" argument must be of type string. Received an instance of Object at validateString (internal/validators.js:117:11) at ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The SVGO config format changed: https://github.com/sindresorhus/gulp-imagemin/commit/a1579c0a88232f58ce2b8b5e95e24570240fb1a4
Hi there. Sorry for noticing so late. Currently, I don’t have resources to try it out, so I’ll close the issue and reopen it if anything goes wrong. Thanks!