"sideEffects" is false in the enclosing "package.json" file
I am trying to publish my project to Cloudflare Pages, but I get the following error when I try to run the project. This is from running it localy with Wrangler, but there are the same errors when it's published to CF Pages.
""sideEffects" is false in the enclosing "package.json" file"
Any idea why this is? I have trouble making a minimal viable version.
9 Replies
Hi @TOMOLAI. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Based on the knowledge sources, I can see that you're encountering an issue with Cloudflare Pages deployment for your Nuxt project. The specific error about "sideEffects" being false in the package.json file isn't directly addressed in the provided knowledge sources, but there are several related Cloudflare Pages deployment issues that might help us understand what's happening.
Several users have reported different errors when deploying Nuxt applications to Cloudflare Pages, particularly with recent Nuxt versions. These issues include:
1. Reference errors like "Cannot access '_PerformanceObserver' before initialization" GitHub Issue #31257
2. Issues with the
unenv
dependency GitHub Issue #31290
The "sideEffects: false" error typically relates to tree-shaking in the build process. When a package marks itself as having no side effects, the bundler (like Vite or Webpack) may incorrectly eliminate code that's actually needed at runtime.
Here are some potential solutions based on similar issues:
1. Try configuring Node.js compatibility in your Nuxt config:
2. For Cloudflare Pages specifically, make sure you're using the correct build command:
3. If you're using Nuxt Content, follow the specific Cloudflare Pages deployment instructions from Content Nuxt documentation.
4. Check if you have any dependencies that might be causing conflicts. Some users found that updating or manually adding unenv
as a dev dependency helped resolve similar issues.
5. Make sure Cloudflare's "Minification and Security Options" are properly configured as mentioned in the Nuxt deployment documentation.
If these solutions don't work, you might need to create a minimal reproduction of the issue to get more specific help from the Nuxt community, as mentioned by the maintainers in the GitHub issues.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@112198323695280128> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
Option one worked, then when I removed the usage of Nuxt Script the project worked again.
TypeError: Cannot read properties of undefined (reading 'entries')
at .wrangler/tmp/pages-oH8Vyj/chunks/build/useTracker.mjs
(file:///home/asus/projects/no-engagement/.wrangler/tmp/pages-oH8Vyj/chunks/build/useTracker.mjs:1:6901)
at init
(file:///home/asus/projects/no-engagement/.wrangler/tmp/dev-jlUmWu/1aqsn110syv.js:5:59)
at .wrangler/tmp/pages-oH8Vyj/chunks/build/index.vue.mjs
(file:///home/asus/projects/no-engagement/.wrangler/tmp/pages-oH8Vyj/chunks/build/index.vue.mjs:1:607)
at init
(file:///home/asus/projects/no-engagement/.wrangler/tmp/dev-jlUmWu/1aqsn110syv.js:5:59)
at null.<anonymous>
(file:///home/asus/projects/no-engagement/.wrangler/tmp/pages-oH8Vyj/chunks/build/server.mjs:1:123353)
Please look at this error @kapa.ai
Let me check the knowledge base for you again. One moment! :books:
----------------------
I'd be happy to help you with your error, but I need more details about the specific error you're encountering. The previous conversation mentioned an error about "sideEffects" being false in your package.json file when deploying to Cloudflare Pages, but I need to know if you're still experiencing that same error or if you're now facing a different issue.
Could you please share:
1. The complete error message you're seeing
2. Any steps you've taken since our last conversation
3. Your Nuxt version and configuration details
With more specific information about the error, I'll be better able to provide relevant assistance based on the knowledge sources available.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
<@112198323695280128> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
I build the project for Cloudflare Pages, I have the latest version of nuxt and nuxt script and I use Meta pixel, Google analytics etc. When I remove tracking scripts the website works again. The above is the error message i get. @kapa.ai
@kapa.ai
Let me check the knowledge base for you again. One moment! :books:
Sorry @TOMOLAI, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?
I build the project for Cloudflare Pages, I have the latest version of nuxt and nuxt script and I use Meta pixel, Google analytics etc. When I remove tracking scripts the website works again. The above is the error message i get. @kapa.ai
TypeError: Cannot read properties of undefined (reading 'entries')
at .wrangler/tmp/pages-oH8Vyj/chunks/build/useTracker.mjs
(file:///home/asus/projects/no-engagement/.wrangler/tmp/pages-oH8Vyj/chunks/build/useTracker.mjs:1:6901)
at init
(file:///home/asus/projects/no-engagement/.wrangler/tmp/dev-jlUmWu/1aqsn110syv.js:5:59)
at .wrangler/tmp/pages-oH8Vyj/chunks/build/index.vue.mjs
(file:///home/asus/projects/no-engagement/.wrangler/tmp/pages-oH8Vyj/chunks/build/index.vue.mjs:1:607)
at init
(file:///home/asus/projects/no-engagement/.wrangler/tmp/dev-jlUmWu/1aqsn110syv.js:5:59)
at null.<anonymous>
(file:///home/asus/projects/no-engagement/.wrangler/tmp/pages-oH8Vyj/chunks/build/server.mjs:1:123353)
@kapa.ai
Let me check the knowledge base for you again. One moment! :books:
Sorry @TOMOLAI, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?