Is there anyone who has successfully integrated Paddle with Nuxt? I am attempting to incorporate it into a Nuxt app page (component):
<script src="https://cdn.paddle.com/paddle/paddle.js"></script>
<script type="text/javascript">
Paddle.Setup({ vendor: 1234567 });
</script>
I have made several unsuccessful attempts.
- Using NPM with paddle-sdk
https://www.npmjs.com/package/paddle-sdk
The dependencies are outdated and do not work in a modern project. When trying to install npm i --save paddle-sdk, I encounter the following errors. Some of these dependencies are not available through npm:
WARN in ./node_modules/paddle-sdk/node_modules/keyv/src/index.js friendly-errors 09:02:21
Critical dependency: the request of a dependency is an expression friendly-errors 09:02:21
friendly-errors 09:02:21
ERROR Failed to compile with 4 errors friendly-errors 09:02:21
These dependencies were not found: friendly-errors 09:02:21
friendly-errors 09:02:21
* dns in ./node_modules/cacheable-lookup/index.js friendly-errors 09:02:21
* fs in ./node_modules/paddle-sdk/node_modules/got/dist/source/request-as-event-emitter.js, ./node_modules/paddle-sdk/node_modules/got/dist/source/utils/get-body-size.js
* net in ./node_modules/paddle-sdk/node_modules/got/dist/source/utils/timed-out.js friendly-errors 09:02:21
friendly-errors 09:02:21
To install them, you can run: npm install --save dns fs net friendly-errors 09:02:21
- Trying Nuxt Plugins
https://nuxtjs.org/docs/2.x/directory-structure/plugins/
It seems impossible to create a nuxt plugin with an external (third party) script, only local scripts in the plugins directory. According to Paddle's website, they advise against self-hosting Paddle.js as it may prevent you from receiving updates and new features.
- Utilizing the Head method
I have managed to include the script using the head method within the page, but I cannot execute methods from the script on the nuxt page. In other words, this works:
<script src="https://cdn.paddle.com/paddle/paddle.js"></script>
But this does not:
<script type="text/javascript">
Paddle.Setup({ vendor: 1234567 });
</script>
Below is the head portion of my .vue file:
head: {
script: [
{
hid: 'Paddle',
src: 'https://cdn.paddle.com/paddle/paddle.js',
async: true,
defer: false
}
]
},
Has anyone found a solution or alternative approach?