Error when using Vite (Vue 3)
See original GitHub issueExpected Behavior
There is an error running applications using Vite (https://github.com/vitejs/vite). After installing the dependency using yarn add contentful
and then running yarn dev
, the server should start normally but fails with an error.
Actual Behavior
Running yarn dev
will cause the server to error with the following error:
[vite] Dep optimization failed with error:
'platform' is not exported by node-resolve:empty.js, imported by node_modules/contentful-sdk-core/dist/index.es-modules.js
Error: 'platform' is not exported by node-resolve:empty.js, imported by node_modules/contentful-sdk-core/dist/index.es-modules.js
at error (<project dir>/node_modules/rollup/dist/shared/rollup.js:5231:30)
at Module.error (<project dir>/node_modules/rollup/dist/shared/rollup.js:9787:16)
at handleMissingExport (<project dir>/node_modules/rollup/dist/shared/rollup.js:9676:28)
at Module.traceVariable (<project dir>/node_modules/rollup/dist/shared/rollup.js:10177:24)
at ModuleScope.findVariable (<project dir>/node_modules/rollup/dist/shared/rollup.js:8708:39)
at FunctionScope.findVariable (<project dir>/node_modules/rollup/dist/shared/rollup.js:2781:38)
at ChildScope.findVariable (<project dir>/node_modules/rollup/dist/shared/rollup.js:2781:38)
at Identifier$1.bind (<project dir>/node_modules/rollup/dist/shared/rollup.js:4137:40)
at CallExpression$1.bind (<project dir>/node_modules/rollup/dist/shared/rollup.js:2867:23)
at CallExpression$1.bind (<project dir>/node_modules/rollup/dist/shared/rollup.js:6605:15) {
code: 'MISSING_EXPORT',
url: 'https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module',
id: '<project dir>/node_modules/contentful-sdk-core/dist/index.es-modules.js',
pos: 122,
loc: {
file: '<project dir>/node_modules/contentful-sdk-core/dist/index.es-modules.js',
line: 4,
column: 9
},
frame: "2: import qs from 'qs';\n" +
"3: import isPlainObject from 'lodash/isPlainObject';\n" +
"4: import { platform, release } from 'os';\n" +
' ^\n' +
'5: \n' +
'6: function _defineProperty(obj, key, value) {',
<watch section omitted>
Possible Solution
The error directs you to the following page: https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module
Steps to Reproduce
yarn create vite-app someproject
cd someproject
yarn add contentful
yarn install
yarn dev
Context
Vite seems to be (?) the recommended CLI tool for Vue 3 development. We are having trouble proting our app to vue 3 due to this error.
Environment
- Vite:
v1.0.0-rc.4
- Vue:
v3.0.0
- Language Version: v14.5.0
- Package Manager Version: yarn 1.22.4
- Operating System: Linux 64 bit (Ubuntu 20.04)
- Package Version: 7.14.8
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Troubleshooting
Syntax Error / Type Error happens Vite cannot handle and does not support code that only runs on non-strict mode (sloppy mode). This...
Read more >Vue3 + Vite: error handling in production
But when I use this code in production, the code gets bundled (using Vite) and then the error handling is not useful anymore....
Read more >Error when running test with vitest + vue3 + vite on ...
Hello,. I'm seeing the following error when running a unit test on a custom component that has a Syncfusion Dialog inside it. Error:....
Read more >Building a Vue3 Typescript Environment with Vite - miyauci.me
Building a Typescript Vue3 environment using the No bundle tool Vite, along with ESLint and Prettier configuration to create a high DX environment....
Read more >[Solved]-getting error on vite build in vue3 vite project-Vue.js
In some npm packages, I have used in my project have some features were added from the latest EcmaScript. Like async generator functions,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
A workaround for now:
I’ve just updated to
9.0.0
, works like a charm. Thank you @marcolink!