vite-ssr icon indicating copy to clipboard operation
vite-ssr copied to clipboard

vite-ssr doesn't appear to be written in CJS, but also doesn't appear to be a valid ES module (i.e. it doesn't have "type": "module" or an .mjs extension for the entry point). Please contact the package author to fix.

Open Carseason opened this issue 2 years ago • 8 comments

"dependencies": { "@vueuse/head": "^0.7.6", "axios": "^0.26.1", "element-plus": "^2.1.9", "express": "^4.17.3", "pinia": "^2.0.13", "sass": "^1.50.0", "vite-ssr": "^0.16.0", "vue": "3", "vue-router": "4" }, "devDependencies": { "@types/node": "^17.0.24", "@vitejs/plugin-vue": "^2.3.1", "typescript": "^4.6.3", "vite": "^2.9.5", "vue-tsc": "^0.34.7" }

Carseason avatar Apr 18 '22 13:04 Carseason

Make sure you set "type": "module" in your packge.json

m3hari avatar Apr 19 '22 07:04 m3hari

ok,Me Not paying attention to new changes

Carseason avatar Apr 19 '22 09:04 Carseason

I had this problem too, and adding "type": "module" didn't fix it image

LittleSound avatar Apr 28 '22 07:04 LittleSound

@LittleSound

me to

Carseason avatar May 09 '22 07:05 Carseason

+1

ElBouhaliMohamed avatar May 13 '22 23:05 ElBouhaliMohamed

You can safely ignore that warning for now. We will probably drop CJS support at some point (perhaps with Vite v3).

frandiox avatar May 16 '22 03:05 frandiox

I found that adding module.exports = 'i love you' to the index.js of the package fixes the issue.

Looking into the vite code that logs the message, I found a regex check right before it logs. image

The regex just checks for some key works for CJS image

These are in a function called collectExternals, I wasn't able to find the source in github.

MichealPearce avatar Jun 20 '22 05:06 MichealPearce

Also found it could be fixed by just adding module.exports as a comment image

MichealPearce avatar Jun 20 '22 05:06 MichealPearce