sindresorhus / filenamify

Convert a string to a valid safe filename
MIT License
489 stars 26 forks source link

Can't resolve 'node:path' #36

Closed duytranvinh closed 2 years ago

duytranvinh commented 2 years ago

Hi,

I got the following error

Failed to compile.

./node_modules/filenamify/filenamify-path.js
Module not found: Can't resolve 'node:path' in 'xxx\node_modules\filenamify'
sindresorhus commented 2 years ago

This is a problem with your build tool or its config, not this package.

TiagoDanin commented 1 year ago

This does not work in react native due to the above problem.

Today I used patch-package to patch filenamify@6.0.0 for the project I'm working on.

Here is the diff that solved my problem (removed the filenamify-path):

diff --git a/node_modules/filenamify/filenamify-path.js b/node_modules/filenamify/filenamify-path.js
index 101e0f5..9c7b8be 100644
--- a/node_modules/filenamify/filenamify-path.js
+++ b/node_modules/filenamify/filenamify-path.js
@@ -1,7 +1 @@
-import path from 'node:path';
-import filenamify from './filenamify.js';
-
-export default function filenamifyPath(filePath, options) {
-   filePath = path.resolve(filePath);
-   return path.join(path.dirname(filePath), filenamify(path.basename(filePath), options));
-}
+export default function filenamifyPath(filePath, options) {}