1

When trying to install the [Razor Pay library][1] [1]: https://www.npmjs.com/package/nativescript-razorpay, I get the following error:

ERROR in ./node_modules/nativescript-razorpay/razorpay.android.js 3:20-59 Module not found: Error: Can't resolve 'tns-core-modules/application' resolve 'tns-core-modules/application' Parsed request is a module

Does anyone know what can be done to resolve this error? Or do we need to rewrite the plugin to the newest version of the nativescript, in order for this to run?

Kamil Kafoor
  • 256
  • 3
  • 8

2 Answers2

2

You can find your answer here: https://blog.nativescript.org/nativescript-7-for-plugin-authors/

basically you should change

'tns-core-modules/application'

to this

'@nativescript/core'
oded bartov
  • 391
  • 1
  • 2
  • 9
0

I found out that most likely doesn't need a full rewrite, just a few import updates for ns7/8 to use @nativescript/core imports.

You may be able to get it working with a webpack alias as well - though ideally the plugin should be updated...

webpack.chainWebpack(config => {
  config.resolve.alias.set('tns-core-modules', '@nativescript/core')
})
Kamil Kafoor
  • 256
  • 3
  • 8
  • I've been migrating a large {N} app from v6 to v8, and there are lots of gotchas such as this. You'll want to search and see if there are newer versions of the plugin available, possibly as separate forks. Lacking that, patch-package is extremely helpful to preserve any local changes you need to make to get a plugin working. – David Feb 17 '22 at 14:40