webpack: Uncaught Error: Cannot find module "."
Do you want to request a feature or report a bug? bug
What is the current behavior? Below exception:
polyfills.js:1 Error: Cannot find module "."
at webpackMissingModule (eval at 148 (http://localhost:9000/assets/app.js:1:576363), <anonymous>:8:65) [angular]
at eval (eval at 148 (http://localhost:9000/assets/app.js:1:576363), <anonymous>:8:144) [angular]
at Object.onInvoke (eval at <anonymous> (http://localhost:9000/assets/vendor.js:1:92060), <anonymous>:4334:37) [angular]
at eval (eval at 142 (http://localhost:9000/assets/polyfills.js:1:6901), <anonymous>:758:57) [angular]
at Object.onInvokeTask (eval at <anonymous> (http://localhost:9000/assets/vendor.js:1:92060), <anonymous>:4325:37) [angular]
at drainMicroTaskQueue (eval at 142 (http://localhost:9000/assets/polyfills.js:1:6901), <anonymous>:591:35) [<root>]
at <anonymous> [<root>]
If the current behavior is a bug, please provide the steps to reproduce. Configuration files are uploaded on Github gist https://gist.github.com/shafaqkazmi/abbf5b07a70e6d23463d2de7d42f2a53
What is the expected behavior? Application should load all desired modules
Please mention other relevant information such as the browser version, Node.js version, webpack version and Operating System.
Version details:
@angular/cli: 1.0.3
node: 7.0.0
os: win32 x64
@angular/common: 4.1.2
@angular/compiler: 4.1.2
@angular/core: 4.1.2
@angular/forms: 4.1.2
@angular/http: 4.1.2
@angular/platform-browser: 4.1.2
@angular/platform-browser-dynamic: 4.1.2
@angular/router: 4.1.2
@angular/cli: 1.0.3
@angular/compiler-cli: 4.1.2
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 11
- Comments: 57 (1 by maintainers)
Links to this issue
Commits related to this issue
- Don't use expression in require statement. This can seemingly cause problems in webpack (see webpack/webpack#4921). — committed to urbit/azimuth-js by jtobin 6 years ago
I think i found a solution, at least for Ionic. I have no idea what’s causing this, but it appears that i get the error when some imports add “/umd” at the end. For instance:
import { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular/umd';
i made a search in the whole project looking for “/umd” and deleted them:import { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular';
, and it worked!I had two projects with the same problem, and i fixed both by doing this… Again, i don’t know if it’s VS Code Insiders that’s automaticly adding this or a plugin i have installed or something…
Are you all using VS Code?
Happened to me as well, turns out it was because i was using require with an expression instead of a value:
Since module resolution is static - variables are not allowed, so you could just go with
it helped me:
and if you need more variable in your dynamic path try split require:
npm i -D typescript@2.8.3
fixed it for me.http://cabanalabs.com/2016/05/04/how-to-fix-webpack-when-it-cant-find-your-modules/
@danielzlotnik +1 Is there a solution?
Ran into the same issue (not using Ionic), unable to use template literals within the require after upgrading to Babel 7. We are currently using webpack 2.x and will be upgrading to 4 soon - I believe this has to do with new babel + older webpack not being friendly in my scenario.
Not Working
Working
This is the temporary fix I’ve applied that works for me. Hope this helps someone in the future 👍
I’m having this issue, but with import() 😦
Yep, Vs Code added
/umd
to import statement. It could be the auto import plugin. (I am using Vs Code and Ionic)I use the solution proposed by @killian2301. In my case when I did a find/replace in vscode, the postfix /umd was automatically added to the import of the Ionic libraries:
import {Events, Nav, Platform, Config } from 'ionic-angular/umd';
I removed the / umd and with that the error was fixed:
import { Events, Nav, Platform, Config } from 'ionic-angular';
I have the same issue using import in ionic. Any suggestions?
This Solution by @padurets actually solved the issue for me (I’m working on a Vue-Cli 3 project), and I’m getting the path from the Store (Vuex) within a Computed function in my component.
Thanks a lot @padurets !
Decreasing the version to ~2.6.2 fixed it.
In my case it solved the problem by removing
/umd
from import pathes.Search and replace all occurrences of
ionic-angular/umd
withionic-angular
.I don’t know why is
/umd
set on the pathes. And I’m sure it also working with/umd
. The problem comes suddenly. In my case I renamed a few files in my sources. But rebuilt incl. clean. Usually it works. This error (cannot find module “.”) is rare but persistent.@Kaidanov that worked for me too last time…only this time the problem didn’t appear after generating a page, but renaming it…
Me to !! Thank’s really 😂
@killian2301 it works for me. After hours looking for the problem, I solved it remoming all “/umd” statements from all imports that was added when I created a new Page.
@rihlsul Just recompile / restart the app and the styles comes back. I had the same problem. After removing all umd from imports, the html of my app (ionic) was naked. But a rebuild fixed this issue.
Sounds like it’s coming from this: https://github.com/Microsoft/TypeScript/issues/25204
However, when I did replace all on my project to remove all /umd instances, my UI is now borked. Completely unstyled. Will report back if I can figure out what the heck I did.
save my day @killian2301 thought it was just my code structure that causes the fucking error haha 😃
cheers!!!
thanks @killian2301 that’s the perfect solution, in my case the umd comes when use isUndefined function. ;o)
I’m getting the same error with Ionic 3 also… @jayzyaj did you get to solve it? Last time i had to start a new project again…
Can you provide a minimal sample repo that shows that issue?