rn-nodeify: TypeError: main.startsWith is not a function

Got this error today:

rn-nodeify --install buffer,process,console,stream,vm,events,path --hack

not overwriting "buffer"
not overwriting "process"
not overwriting "console-browserify"
not overwriting "stream-browserify"
not overwriting "vm-browserify"
not overwriting "events"
not overwriting "path-browserify"
not overwriting "readable-stream"
not overwriting shim.js. For the latest version, see rn-nodeify/shim.js
removing browser exclude node_modules/htmlparser2/package.json readable-stream
normalized "main" browser mapping in immediate, fixed here: https://github.com/facebook/metro-bundler/pull/3
normalized "main" browser mapping in lie, fixed here: https://github.com/facebook/metro-bundler/pull/3
normalized "main" browser mapping in pouchdb-find, fixed here: https://github.com/facebook/metro-bundler/pull/3
removing browser exclude node_modules/tweetnacl/package.json buffer
normalized "main" browser mapping in readable-stream, fixed here: https://github.com/facebook/metro-bundler/pull/3
normalized "main" browser mapping in readable-stream, fixed here: https://github.com/facebook/metro-bundler/pull/3
normalized "main" browser mapping in readable-stream, fixed here: https://github.com/facebook/metro-bundler/pull/3
normalized "main" browser mapping in readable-stream, fixed here: https://github.com/facebook/metro-bundler/pull/3
removing browser exclude node_modules/sqlite3/node_modules/tweetnacl/package.json buffer
normalized "main" browser mapping in readable-stream, fixed here: https://github.com/facebook/metro-bundler/pull/3
/usr/local/lib/node_modules/rn-nodeify/cmd.js:327
      const alt = main.startsWith('./') ? main.slice(2) : './' + main
                       ^

TypeError: main.startsWith is not a function
    at /usr/local/lib/node_modules/rn-nodeify/cmd.js:327:24
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:511:3)

Any suggestions?

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 7
  • Comments: 20 (8 by maintainers)

Commits related to this issue

Most upvoted comments

Could not fix this issue until updated dependency:

-    "rn-nodeify": "github:mvayngrib/rn-nodeify"
+    "rn-nodeify": "github:tradle/rn-nodeify"

I had the same issue since today. It was caused by package browserify/resolve, which introduced invalid package.json in its tests:

"main": [
  "why is this a thing",
  "srsly omg wtf"
]

This package.json is parsed by rn-nodeify and results in this error. As a workaround you may force version 1.8.1 of resolve in package.json of your project.

@shardick @Vanclief put it in dependencies in your package.json, but be sure to point to exact version (“compatible” may allow 1.9.0).

Looking through package-lock.json, it would seem that resolve is required by @babel/core which in turn is required by metro, React Native packager.

same problem here. @mboguc how force resolve version?

@nyl9488 maybe you put it in a wrong place. It should be in the dependencies section and with “1.8.1” exactly. And check what version in your package-lock.json. If you’ll see 1.9.0 - that’s bad. Try reinstall with: npm install --save resolve@1.8.1

Also, there’s already a fix for this issue, I hope @mvayngrib will publish this package soon so we can use it without forcing version.

I’ve added a check if main isn’t a string for such cases.