When integrating old nativescript libraries throws Module not found: Error: Can't resolve 'tns-core-modules/application'

2.1k Views Asked by At

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?

2

There are 2 best solutions below

1
Kamil Kafoor On

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')
})
0
oded bartov On

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'