Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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. #159

Open
Carseason opened this issue Apr 18, 2022 · 8 comments

Comments

@Carseason
Copy link

"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"
}

@m3hari
Copy link
Collaborator

m3hari commented Apr 19, 2022

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

@Carseason
Copy link
Author

ok,Me Not paying attention to new changes

@LittleSound
Copy link
Contributor

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

@Carseason Carseason reopened this May 9, 2022
@Carseason
Copy link
Author

@LittleSound

me to

@ElBouhaliMohamed
Copy link

+1

@frandiox
Copy link
Owner

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

@MichealPearce
Copy link

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants