Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DEP0180] DeprecationWarning: fs.Stats constructor is deprecated. #356

Open
2 of 4 tasks
kashav opened this issue Aug 19, 2024 · 1 comment
Open
2 of 4 tasks

[DEP0180] DeprecationWarning: fs.Stats constructor is deprecated. #356

kashav opened this issue Aug 19, 2024 · 1 comment

Comments

@kashav
Copy link

kashav commented Aug 19, 2024

Before you open this issue, please complete the following tasks:

  • use the search bar at the top of the page to search this repository for similar issues or discussions that have already been opened.
  • if you are looking for help from the gulp team or community, open a discussion.
  • if you think there is a problem with the plugin you're using, open a discussion.
  • if you think there is a bug in our code, open this issue.

What were you expecting to happen?

No deprecation warning.

What actually happened?

Deprecation warning for the fs.Stats constructor.

Please give us a sample of your gulpfile

// src/zip.js
import gulp from 'gulp'
import zip from 'gulp-zip'
import { createRequire } from 'module'
const require = createRequire(import.meta.url)
const manifest = require('../build/manifest.json')

gulp
  .src('build/**')
  .pipe(zip(`${manifest.name.replaceAll(' ', '-')}-${manifest.version}.zip`))
  .pipe(gulp.dest('package'))

Terminal output / screenshots

$ node --trace-deprecation src/zip.js
(node:59666) [DEP0180] DeprecationWarning: fs.Stats constructor is deprecated.
    at Transform.normalize [as _transform] (/node_modules/vinyl-fs/lib/dest/prepare.js:38:32)
    at Transform._write (/node_modules/streamx/index.js:981:12)
    at WritableState.update (/node_modules/streamx/index.js:187:16)
    at WritableState.updateWriteNT (/node_modules/streamx/index.js:550:10)
    at process.processTicksAndRejections (node:internal/process/task_queues:77:11)

Please provide the following information:

  • OS & version [e.g. MacOS Catalina 10.15.4]: n/a
  • node version (run node -v): v22.3.0
  • npm version (run npm -v): 10.8.1
  • gulp version (run gulp -v): CLI version: 3.0.0 / Local version: 5.0.0

Additional information

API was deprecated in Node v22.0.0 - https://nodejs.org/api/deprecations.html#DEP0180:

Calling fs.Stats class directly with Stats() or new Stats() is deprecated due to being internals, not intended for public use.

Docs also mention:

Stat objects are not to be created directly using the new keyword.

Not sure what the alternative is here. Maybe just use fs.statSync() or return an empty object if the file doesn't exist?

@phated
Copy link
Member

phated commented Aug 19, 2024

This library currently supports node 10+. This cannot be resolved until older node support is dropped.

@gulpjs gulpjs locked and limited conversation to collaborators Aug 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants