tradle / rn-nodeify

hack to allow react-native projects to use node core modules, and npm modules that use them
MIT License
614 stars 114 forks source link

bug: pbkdf2 Unexpected token #102

Closed adeyahya closed 3 years ago

adeyahya commented 3 years ago

Hi! πŸ‘‹

Firstly, thanks for your work on this project! πŸ™‚

Today I used patch-package to patch rn-nodeify@10.2.0 for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/rn-nodeify/pkg-hacks.js b/node_modules/rn-nodeify/pkg-hacks.js
index 25f4dbd..bca6d35 100644
--- a/node_modules/rn-nodeify/pkg-hacks.js
+++ b/node_modules/rn-nodeify/pkg-hacks.js
@@ -520,7 +520,7 @@ var hackers = [
     hack: function (file, contents) {
       if (isInReactNative(file)) return

-      var fixed = contents.replace('process.version', '"' + process.version + '"')
+      var fixed = contents.replace(/\.+process\.version/g, '["' + process.version + '"]')

       return contents === fixed ? null : fixed
     }

This issue body was partially generated by patch-package.

mvayngrib commented 3 years ago

@adeyahya what version of pbkdf2 are you using?

vuongpsht commented 3 years ago

add this one to your package.json

"resolutions": { "**/pbkdf2": "3.1.1", "**/**/pbkdf2": "3.1.1", "**/**/**/pbkdf2": "3.1.1" },