I am using Piwik with a Nuxt.js project. I added “@piwikpro/nuxt-piwik-pro”,
{
containerId:
process.env.PIWIK_PRO_CONTAINER_ID ,
containerUrl:
process.env.PIWIK_PRO_CONTAINER_URL,
} In modules in the nuxt.config file as shown on nuxt-piwik-pro/example/nuxt.config.ts at master · PiwikPRO/nuxt-piwik-pro · GitHub. This works fine on localhost but when I try to deploy it I get " [error] @piwikpro/nuxt-piwik-pro module cannot run without ‘containerUrl’ and ‘containerId’ because they are required. Pass them as a module inline-options." I verified that the value are set correctly as environment variables with the hosting provider. What could be causing this?
Hi Salma
Our team deployed a Nuxt application to double check the issue (using the same methods you mentioned in your post). It seems like the error you’re getting can only occur when containerId or containerUrl is not passed to the integration plugin or its value is empty. The conclusion is that if these values are passed using process.env (and everything works as expected in local), the environment variables might not have been defined properly or there may be a typo somewhere.
Thank you for your reply. When I tried passing the values of containerUrl and containerId directly in the config file instead of passing them through environment variables it worked fine. I do have other values that are not Piwik related set as environment variables and they are working correctly so I am not sure why these Piwik associated values are not. And I have checked multiple times that the values passed are correct and there are not any typos.
Is it important to have them passed as environment variables?
It’s a good practice, but it’s not necessary. ContainerId and containerUrl are passed to the integration plugin by value, so from the plugin’s perspective, it doesn’t matter where they come from. It seems like these variables aren’t loading into the environment context (or, for instance, they are loading after the Nuxt configuration initialization). It’s hard to pinpoint why since we don’t exactly know your setup.