Comments (10)
I had the same issue. In my case the reason was a typo in dynamic import:
import(/* webpackChunkName: "locale-[request]" */ @/locales/${locale})
It seems the '@' symbol is not supported in the path.
from friendly-errors-webpack-plugin.
If you are building on Render or Netlify make sure require.context("~/middleware", false, /.*\.js$/)
does not point to an empty directory or else it will fail with a TypeError
. At least that was my issue.
It passes on local builds when I run npm run production
or dev
but fails when I try to build online on both of these services.
Stack:
└─┬ [email protected]
└── [email protected]
└── [email protected]
Error message:
TypeError: Cannot read property 'startsWith' of undefined
at isRelative (/opt/render/project/src/node_modules/friendly-errors-webpack-plugin/src/formatters/moduleNotFound.js:5:17)
at /opt/render/project/src/node_modules/friendly-errors-webpack-plugin/src/formatters/moduleNotFound.js:64:15
at Array.map (<anonymous>)
at groupModules (/opt/render/project/src/node_modules/friendly-errors-webpack-plugin/src/formatters/moduleNotFound.js:62:43)
at formatErrors (/opt/render/project/src/node_modules/friendly-errors-webpack-plugin/src/formatters/moduleNotFound.js:74:18)
at format (/opt/render/project/src/node_modules/friendly-errors-webpack-plugin/src/formatters/moduleNotFound.js:87:10)
at format (/opt/render/project/src/node_modules/friendly-errors-webpack-plugin/src/core/formatErrors.js:12:33)
at Array.map (<anonymous>)
at formatErrors (/opt/render/project/src/node_modules/friendly-errors-webpack-plugin/src/core/formatErrors.js:15:21)
at FriendlyErrorsWebpackPlugin.displayErrors (/opt/render/project/src/node_modules/friendly-errors-webpack-plugin/src/friendly-errors-plugin.js:110:5)
at doneFn (/opt/render/project/src/node_modules/friendly-errors-webpack-plugin/src/friendly-errors-plugin.js:51:14)
at AsyncSeriesHook.eval [as callAsync] (eval at create (/opt/render/project/src/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:7:1)
at AsyncSeriesHook.lazyCompileHook (/opt/render/project/src/node_modules/tapable/lib/Hook.js:154:20)
at onCompiled (/opt/render/project/src/node_modules/webpack/lib/Compiler.js:271:21)
at /opt/render/project/src/node_modules/webpack/lib/Compiler.js:681:15
at AsyncSeriesHook.eval [as callAsync] (eval at create (/opt/render/project/src/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:4:1)
at AsyncSeriesHook.lazyCompileHook (/opt/render/project/src/node_modules/tapable/lib/Hook.js:154:20)
at /opt/render/project/src/node_modules/webpack/lib/Compiler.js:678:31
at AsyncSeriesHook.eval [as callAsync] (eval at create (/opt/render/project/src/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:4:1)
at AsyncSeriesHook.lazyCompileHook (/opt/render/project/src/node_modules/tapable/lib/Hook.js:154:20)
at /opt/render/project/src/node_modules/webpack/lib/Compilation.js:1423:35
at AsyncSeriesHook.eval [as callAsync] (eval at create (/opt/render/project/src/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:4:1)
at AsyncSeriesHook.lazyCompileHook (/opt/render/project/src/node_modules/tapable/lib/Hook.js:154:20)
at /opt/render/project/src/node_modules/webpack/lib/Compilation.js:1414:32
at eval (eval at create (/opt/render/project/src/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:12:1)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
from friendly-errors-webpack-plugin.
@Ghustavh97 goddamn i love you
from friendly-errors-webpack-plugin.
@timefordroids for me it's not related to a @
but to the use of dynamic plugin name.
It seems to be a bug in this plugin (friendly-errors-webpack-plugin
) when the moduleNotFound.js
formatter is matched (e.type === 'module-not-found'
) and the error.module
property is undefined
which can happen when dynamic module names are used (ie with a var). It then tries to error.module.startsWith(...)
within the isRelative
helper, which fails since error.module
is undefined
.
from friendly-errors-webpack-plugin.
...tho it used to work for me before as is, not sure what I've updated (at least I did not update the package which I am requiring files from) ... sounds like a webpack issue then. When I inspect the webpack error object, the require()
that I am using should be working. It can't find... an existing directory. I need to investigate more...
from friendly-errors-webpack-plugin.
I was extracting some code into a different package and used file:
to reference it:
{
"dependencies": {
"my-lib": "file:../my-lib"
}
}
I made a mistake in the lib and had a require('./filename')
in the index.js.
After building my original project I received the same error signature reported in this issue.
from friendly-errors-webpack-plugin.
I am getting this as well.
from friendly-errors-webpack-plugin.
Hi there. I got a quite similar similar problem. And I took these screenshots:
I tried to track the problem and found it. Seems to be using the wrong key in the error map:
In my case, I tried to load a components dynamic but not exist. After fixed the path and the problem is gone.
The problem seems to be at src/formatters/moduleNotFound.js#L62, where use a map to store missing modules but may got an undefined
as map's key if a components is loaded dynamic.
from friendly-errors-webpack-plugin.
I had added an alias to my /src
using the @
symbol. It worked initially, but then it broke later for whatever reason. I changed the alias key from @
to src
and that fixed everything :)
from friendly-errors-webpack-plugin.
from friendly-errors-webpack-plugin.
Related Issues (20)
- Blank error when only webpackError property populated
- module is undefined
- show time even if warning appears
- Missing Error Filtering Feature
- Stylelint output does not show the name of the file where warnings occur
- Cannot read property 'request' of undefined at transform HOT 2
- Cannot read property 'some' of undefined
- Missing error report for failed compilation
- Can this plugin work with ForkTsChecker plugin when clearConsole is true? HOT 7
- Is 2.x ready for release? HOT 2
- compilationSuccessInfo.message not show HOT 1
- Peer Dependency issue with Webpack v5.x HOT 4
- Type 'FriendlyErrorsWebpackPlugin' is not assignable to type 'WebpackPluginInstance'.
- Forget update the Readme on NPM HOT 1
- Cannot read property 'startsWith' of undefined HOT 2
- should not output warning when the count of warnings is 0 HOT 4
- Support for displaying compilationSuccessInfo only on initial compilation HOT 1
- Does not work with Node.js v12 HOT 2
- recommending a different eslint-loader formatter in the docs
- Compilation is always succesful when it should not be HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from friendly-errors-webpack-plugin.