My very non-smart brain really wanted for me to use React.
I chose Vite because I used it, WITH NO PROBLEMS.
NOW
I keep getting this error on Termux:
failed to load config from /data/data/com.termux/files/home/react/vite.config.js error when starting dev server: Error: Failed to load native binding at Object.<anonymous> (/data/data/com.termux/files/home/react/node_modules/@swc/core/binding.js:333:11) at Module._compile (node:internal/modules/cjs/loader:1504:14) at Module._extensions..js (node:internal/modules/cjs/loader:1588:10) at Module.load (node:internal/modules/cjs/loader:1282:32) at Module._load (node:internal/modules/cjs/loader:1098:12) at TracingChannel.traceSync (node:diagnostics_channel:315:14) at wrapModuleLoad (node:internal/modules/cjs/loader:215:24) at Module.require (node:internal/modules/cjs/loader:1304:12) at require (node:internal/modules/helpers:123:16) at Object.<anonymous> (/data/data/com.termux/files/home/react/node_modules/@swc/core/index.js:49:17)
My Vite config is:
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react-swc'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
server: {
host: '0.0.0.0',
port: 6969
},
build: {
sourcemap: true
}
})
STEPS TO REPRODUCE:
1.) Create a Vite app
2.) Choose React, and JavaScript + SWC
3.) Change directory to it
4.) Install the dependencies using npm i
5.) Run a development locally hosted web by using npm run dev
I was expecting to work properly, as in with no errors
2
Answers
In my case, this problem was related to the fact that I used a package-lock.json from my repository. This package was generated on a Windows system and therefore lacked dependencies that are necessary for the Linux operating system used in Docker. Like rollup-linux-arm64-musl or rollup-linux-powerpc64le-gnu and etc. So, I’ve modified my docker file.
node_modules and package-lock.json were added to .dockerignore file.
It’s helped to fix not only this issue and other issues related with this nuance as well.
What’s interesting is that when the node_modules directory was deleted and the npm i was re-run, a package-lock.json file contained all the necessary dependencies and there were no problems with the build for a docker. But if you delete a package-lock.json and re-run the npm i, the necessary dependencies were no longer there and this problem appeared.
I’m facing a similar problem.
Try install npm i -D @swc/core. It helped me.