question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"Module not found: Can't resolve imported dependency "fs"" after upgrading to v2 when using the MonacoEditor component

See original GitHub issue

Describe the bug After upgrading Quasar to v2 like it worked for another project I got a lot of Module not found errors. Most of these could be resolved by implementing this: https://github.com/quasarframework/quasar/issues/9780#issuecomment-867168502. However, from the docs it seems like this isn’t the preferred solution and some errors remained. The remaining errors can be found below.

It’s probably caused by using the monaco-editor component which has more (or some specific) features than QuasarEditor which is why I used it. How to solve this (probably trivial)?

 App • Chaining "Renderer" Webpack config
 App • Extending "Renderer" Webpack config
 App •  WAIT  • Compiling of "Renderer" in progress...
 App •  DONE  • "Renderer" compiled with errors • 14297ms



 App •  ERROR  •  Renderer  in ./node_modules/graceful-fs/graceful-fs.js

Module not found: Can't resolve imported dependency "fs"
Did you forget to install it? You can run: npm install --save fs

 App •  ERROR  •  Renderer  in ./node_modules/jest-worker/build/workers/ChildProcessWorker.js

Module not found: Can't resolve imported dependency "child_process"
Did you forget to install it? You can run: npm install --save child_process

 App •  ERROR  •  Renderer  in ./node_modules/jest-worker/build/workers/NodeThreadsWorker.js

Module not found: Can't resolve imported dependency "worker_threads"
Did you forget to install it? You can run: npm install --save worker_threads

 App •  ERROR  •  Renderer  in ./node_modules/loader-runner/lib/LoaderRunner.js

Module not found: Can't resolve imported dependency "fs"
Did you forget to install it? You can run: npm install --save fs

 App •  ERROR  •  Renderer  in ./node_modules/monaco-editor-webpack-plugin/out/index.js

Module not found: Can't resolve imported dependency "fs"
Did you forget to install it? You can run: npm install --save fs

 App •  ERROR  •  Renderer  in ./node_modules/terser/node_modules/source-map/lib/read-wasm.js

Module not found: Can't resolve imported dependency "fs"
Did you forget to install it? You can run: npm install --save fs

 App •  ERROR  •  Renderer  in ./node_modules/watchpack/lib/LinkResolver.js

Module not found: Can't resolve imported dependency "fs"
Did you forget to install it? You can run: npm install --save fs

 App •  ERROR  •  Renderer  in ./node_modules/webpack/lib/config/defaults.js

Module not found: Can't resolve imported dependency "fs"
Did you forget to install it? You can run: npm install --save fs


 App •  COMPILATION FAILED  • Please check the log above for details.

Codepen/jsFiddle/Codesandbox (required)

To Reproduce Steps to reproduce the behavior:

  1. Upgrade a project using the monacoeditor component from v1 to v2 and remove and readd electron mode to upgrade electron (it worked with v1)
  2. Implement https://github.com/quasarframework/quasar/issues/9780#issuecomment-867168502
  3. Run quasar dev -m electron -- --no-sandbox --disable-setuid-sandbox (or quasar dev -m electron)

Expected behavior Expected step 2 to not be necessary or not be a little risky and the project to build via step 3.

Screenshots

Platform (please complete the following information): Quasar Version: @quasar/app Version:3.0.3

Quasar mode:

  • SPA
  • SSR
  • PWA
  • Electron
  • Cordova
  • Capacitor
  • BEX

Tested on:

  • SPA
  • SSR
  • PWA
  • Electron
  • Cordova
  • Capacitor
  • BEX

OS:Debian10/KDE Node:v12.22.2 NPM:7.20.3 Yarn: Browsers: iOS: Android: Electron:13.1.7

Additional context

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:17 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
mYnDstrEAmcommented, Aug 5, 2021

It was because I still had import TheMonacoEditor from 'vue-monaco' somewhere. Got it to work now (like in the readme of monaco-editor-webpack-plugin and without a component): <div id="container" style="height: 500px; width: 500px;" /> and

mounted() {
    TheMonacoEditor.editor.create(document.getElementById("container"), {
      value: 'console.log("Hello, world")',
      language: "javascript",
    });
  },

Thank you very much!

1reaction
hawkeye64commented, Aug 4, 2021

I don’t know where that url came from. Try this one: https://quasar.dev/quasar-cli/handling-webpack

I find extendWebpack to be buggy at times, so stick with chainWebpack.

Yes. Don’t forget to import in quasar.conf.js…

const MonacoWebpackPlugin = require("monaco-editor-webpack-plugin");
Read more comments on GitHub >

github_iconTop Results From Across the Web

"Module not found:" compilation error for modules (stream, http ...
"Module not found: Can't resolve imported dependency "fs"" after upgrading to v2 when using the MonacoEditor component #10249.
Read more >
Module not found: Error: Can't resolve 'fs' in React
I want to implement a SASS compiler for my online editor, for this I want to use the npm package " ...
Read more >
resolve.fallback: { "path": false } - You.com - You.com
i tried to Polyfill modules in webpack 5 but not working (Reactjs) ... You cannot use path as webpack doesn't polyfill core node...
Read more >
@monaco-editor/react - npm
Here is an example of a simple integration of monaco editor with a React project. You just need to import and render the...
Read more >
How to fix 'Module not found: Can't resolve 'http' in ... - YouTube
Basically, just change 'react-scripts' to 4.0. 2 in your package.json and run `npm install` again :D Follow me on Twitter: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found