0

How do I get rid of this error?

Module not found: Error: You attempted to import /home/sebastian/dev/frontend/node_modules/browserify-zlib/lib/index.js which falls outside of the project src/ directory. Relative imports outside of src/ are not supported.
You can either move it inside src/, or add a symlink to it from project's node_modules/.

I was able to get rid of this error by doing sudo FAST_REFRESH=false npm run start:

Module not found: Error: You attempted to import /home/sebastian/dev/frontend/node_modules/react-refresh/runtime.js which falls outside of the project src/ directory. Relative imports outside of src/ are not supported.
You can either move it inside src/, or add a symlink to it from project's node_modules/.

My craco.config.js file:

const webpack = require("webpack");
const NodePolyfillPlugin = require("node-polyfill-webpack-plugin")
module.exports = {
 webpack: {
 configure: (webpackConfig) => {
 // Ensure symlinks are disabled for cross-platform compatibility
 webpackConfig.resolve.symlinks = false;
 webpackConfig.resolve.modules = [
 'node_modules',
 ...(webpackConfig.resolve.modules || []),
 ];
 webpackConfig.resolve.fallback = {
 process: require.resolve("process/browser"),
 zlib: require.resolve("browserify-zlib"),
 util: require.resolve("util"),
 buffer: require.resolve("buffer"),
 assert: require.resolve("assert"),
 path: require.resolve("path-browserify")
 };
 webpackConfig.plugins.push(
 new webpack.ProvidePlugin({
 Buffer: ["buffer", "Buffer"],
 process: "process/browser.js",
 }),
 new NodePolyfillPlugin({
 excludeAliases: ['console']
 })
 );
 return webpackConfig;
 },
 },
};
asked Feb 25, 2025 at 18:13

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.