Do NOT ignore this template or your issue will have a very high chance to be closed without comment.
I use vite generate a project,Everything is fun after i install less as a dependency.
vite version: 1.0.0-rc.4vue version (from yarn.lock or package-lock.json) 3.0.0-rc.12@vue/compiler-sfc version 3.0.0-rc.12vite or vite build with the --debug flag.[vite] Dep optimization failed with error:
Dependency graceful-fs is attempting to import Node built-in module fs.
This will not work in a browser environment.
Imported by: node_modules/graceful-fs/graceful-fs.js
Tip:
Make sure your "dependencies" only include packages that you
intend to use in the browser. If it's a Node.js package, it
should be in "devDependencies".
If you do intend to use this dependency in the browser and the
dependency does not actually use these Node built-ins in the
browser, you can add the dependency (not the built-in) to the
"optimizeDeps.allowNodeBuiltins" option in vite.config.js.
If that results in a runtime error, then unfortunately the
package is not distributed in a web-friendly format. You should
open an issue in its repo, or look for a modern alternative.
error Command failed with exit code 1.
````
Graceful-fs is a optionalDependency of Less
It's same to sass.
The less should place inside devDependencies instead of dependencies, because vite will optimized the package comes from dependencies.
@underfin we have a similar issue but with server side rendering package which actually should be part of dependencies because it will be used in release while devDependencies like linter, less, sass won't. Does it mean that meaning of dependencies shifted a bit for Vite and it should contain only what is going to be on the client side?
If you don't want this behavior, you can add them into exclude inside optimizeDeps.
If you don't want this behavior, you can add them into
excludeinsideoptimizeDeps.
How to support require
Most helpful comment
If you don't want this behavior, you can add them into
excludeinsideoptimizeDeps.