Seems you already did a lot of coding. So what was the last thing you did before getting the error? I assume it worked at some point?
Jan 11, 2023
3
Level 4
Rollup failed to resolve import "fsevents"
I get this error building a vite + vue3 app inside an Homestead vagrant box. The host machine is Windows 11.
The error appear at the end of npm run build command.
Why is it looking for fsevent? Have you experienced the same problem?
Here is the error message:
vite v4.0.4 building for production...
✓ 333 modules transformed.
[vite]: Rollup failed to resolve import "fsevents" from "/home/vagrant/code/node_modules/rollup/dist/es/shared/rollup.js".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
`build.rollupOptions.external`
error during build:
Error: [vite]: Rollup failed to resolve import "fsevents" from "/home/vagrant/code/node_modules/rollup/dist/es/shared/rollup.js".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
`build.rollupOptions.external`
at onRollupWarning (file:///home/vagrant/code/node_modules/vite/dist/node/chunks/dep-5e7f419b.js:44636:19)
at onwarn (file:///home/vagrant/code/node_modules/vite/dist/node/chunks/dep-5e7f419b.js:44407:13)
at Object.onwarn (file:///home/vagrant/code/node_modules/rollup/dist/es/shared/rollup.js:24461:13)
at ModuleLoader.handleInvalidResolvedId (file:///home/vagrant/code/node_modules/rollup/dist/es/shared/rollup.js:23097:26)
at ModuleLoader.resolveDynamicImport (file:///home/vagrant/code/node_modules/rollup/dist/es/shared/rollup.js:23152:58)
at async file:///home/vagrant/code/node_modules/rollup/dist/es/shared/rollup.js:23043:32
Here is my vite.config.js:
import laravel from 'laravel-vite-plugin'
import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue';
import path from 'path'
export default defineConfig({
buildDirectory: ['build'],
server: {
https: true,
host: '0.0.0.0',
},
plugins: [
laravel([
'./resources/sass/app.scss',
'./resources/js/app.js',
]),
vue({
template: {
transformAssetUrls: {
// The Vue plugin will re-write asset URLs, when referenced
// in Single File Components, to point to the Laravel web
// server. Setting this to `null` allows the Laravel plugin
// to instead re-write asset URLs to point to the Vite
// server instead.
base: null,
// The Vue plugin will parse absolute URLs and treat them
// as absolute paths to files on disk. Setting this to
// `false` will leave absolute URLs un-touched so they can
// reference assets in the public directory as expected.
includeAbsolute: false
},
},
}),
/*{
name: 'blade',
handleHotUpdate({ file, server }) {
if (file.endsWith('.blade.php')) {
server.ws.send({
type: 'full-reload',
path: '*',
});
}
},
},*/
],
resolve: {
alias: {
'~bootstrap': path.resolve(__dirname, 'node_modules/bootstrap'),
'@': '/resources'
}
},
});
Here is my package.json file:
{
"private": true,
"scripts": {
"dev": "vite",
"build": "vite build"
},
"devDependencies": {
"@popperjs/core": "^2.11.6",
"@vitejs/plugin-vue": "^4.0.0",
"axios": "^1.1.2",
"bootstrap": "^5.2.3",
"esbuild": "^0.16.16",
"laravel-vite-plugin": "^0.7.2",
"lodash": "^4.17.19",
"postcss": "^8.1.14",
"sass": "^1.57.1",
"vite": "^4.0.0",
"vue": "^3.2.41",
"vue-router": "^4.1.6"
},
"dependencies": {
"@meforma/vue-toaster": "^1.3.0",
"downloadjs": "^1.4.7",
"highcharts": "^10.3.2",
"humanize-plus": "^1.8.2",
"moment": "^2.29.4",
"moment-timezone": "^0.5.40",
"node-emoji": "^1.11.0",
"prismjs": "^1.29.0",
"stylus": "^0.59.0",
"stylus-loader": "^3.0.2",
"sweetalert2": "^11.6.16",
"vue3-async-computed": "^3.0.0",
"vue3-clipboard": "^1.0.0",
"vuex": "^4.0.2"
}
}
Please or to participate in this conversation.