Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
153
rated 0 times [  156] [ 3]  / answers: 1 / hits: 5865  / 2 Years ago, wed, july 6, 2022, 12:00:00

When trying to build the app with Vite I'm seeing an error. If I understand it correctly there seems to be an issue with Yarn PnP resolving dependencies (no more node_modules), and Vite does not seem to pick up on this? How can I make Vite understand that node_modules no longer exist?


Update: Reproduced test case here: https://github.com/michaeljohansen/vite-test-case - Error seems to go away if removing "type": "module" from package.json, but that makes no sense to me yet, and creates other problems for my Node backend.


$ yarn run vite --config vite.config.js
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'vite' imported from /Users/me/project/vite.config.js
Did you mean to import vite-virtual-ec56a6c02a/0/cache/vite-npm-2.9.13-cda1bb45b9-a5e501b920.zip/node_modules/vite/dist/node/index.js?
at new NodeError (node:internal/errors:377:5)
at packageResolve (node:internal/modules/esm/resolve:910:9)
...

// vite.config.js excerpt
import { defineConfig } from 'vite';

export default defineConfig(({ command, mode }) => {
...
});

More From » node.js

 Answers
0

You need to upgrade to yarn 3.2.0 or above.


yarn set version stable 
# or
yarn set version 3.2.0

And run yarn install to update the .pnp.cjs.
See more at the Change log that they have handle the ESM and commonjs modules.


[#74] Sunday, June 5, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
byronkodyo

Total Points: 552
Total Questions: 87
Total Answers: 104

Location: Burundi
Member since Sat, Aug 21, 2021
3 Years ago
;