Hello! I’ve always deployed applications on netlify without problems. However , this time i’m getting an error after the app has already been deployed. This is the error that i get on the browser console:
Uncaught TypeError: Failed to resolve module specifier “lodash/assign”. Relative references must start with either “/”, “./”, or “…/”.
This isn’t an issue with Netlify. When I try building locally I see
% npm run build
> blog-app@0.0.0 build
> vite build
vite v3.1.4 building for production...
transforming (465) node_modules/react-focus-lock/dist/es2015/Lock.js'lodash/assign' is imported by lodash/assign?commonjs-external, but could not be resolved – treating it as an external dependency
'lodash/cloneDeep' is imported by lodash/cloneDeep?commonjs-external, but could not be resolved – treating it as an external dependency
'lodash/compact' is imported by lodash/compact?commonjs-external, but could not be resolved – treating it as an external dependency
'lodash/difference' is imported by lodash/difference?commonjs-external, but could not be resolved – treating it as an external dependency
'lodash/functions' is imported by lodash/functions?commonjs-external, but could not be resolved – treating it as an external dependency
'lodash/identity' is imported by lodash/identity?commonjs-external, but could not be resolved – treating it as an external dependency
'lodash/includes' is imported by lodash/includes?commonjs-external, but could not be resolved – treating it as an external dependency
'lodash/isArray' is imported by lodash/isArray?commonjs-external, but could not be resolved – treating it as an external dependency
'lodash/isElement' is imported by lodash/isElement?commonjs-external, but could not be resolved – treating it as an external dependency
'lodash/isFunction' is imported by lodash/isFunction?commonjs-external, but could not be resolved – treating it as an external dependency
'lodash/isPlainObject' is imported by lodash/isPlainObject?commonjs-external, but could not be resolved – treating it as an external dependency
'lodash/isString' is imported by lodash/isString?commonjs-external, but could not be resolved – treating it as an external dependency
'lodash/merge' is imported by lodash/merge?commonjs-external, but could not be resolved – treating it as an external dependency
'lodash/trim' is imported by lodash/trim?commonjs-external, but could not be resolved – treating it as an external dependency
✓ 753 modules transformed.
dist/assets/safira.b1769941.png 17.59 KiB
dist/index.html 0.44 KiB
dist/assets/index.f827ba85.css 4.64 KiB / gzip: 0.76 KiB
dist/assets/index.2e9ed859.js 681.31 KiB / gzip: 218.69 KiB
While you haven’t used lodash explicitly as a dependency, several other packages have. I don’t have the answer as I haven’t used ViteJS much. You might have check out the Vite documentation and/or community resources.
I’ve used webpack to bundle the application. Now i’m getting a new error on the console :
Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of “application/octet-stream”. Strict MIME type checking is enforced for module scripts per HTML spec.
I’ve followed the tutorial an got this new error : ReferenceError: React is not defined. Followed a bunch of solutions on stack overflow and could not resolve this error.
Edit : Nevermind. I found out the problem. I was setting babel configuration on both webpack and babel config files.