Webpack - Cannot find module raw-loader

webpack to-string-loader
webpack raw-loader github
create-react-app raw-loader
webpack csv loader
file-loader vs raw-loader
webpack xml-loader
webpack force loader
at-loader cannot find module

I need to load a JS file as a string so I can run some analysis on it. I am trying to use raw-loader with Webpack (2.2.0).

I get: Cannot find module 'raw-loader!../

I've tried (yes, the path is correct):

let app = require('raw-loader!../../app.js').default;

let app = require('!!raw-loader!../../app.js').default;

I've even tried it without inline. Raw-loader doesn't get engaged, it just tried to load the JS file normally:

module.exports = {
  module: {
    rules: [
      {
        test: /\app.js$/i,
        use: 'raw-loader',
        loader: 'raw-loader',
      }
    ]
  }
}

raw-loader is in my package.json for the project. It is present in my node modules. I've blown-away my node_modules and have reinstalled. I've looked at many solutions and nothing seems to point to a fix.


Try adding resolve module extensions, resolve loaders

https://webpack.js.org/configuration/resolve/#resolveloader

https://webpack.js.org/configuration/resolve/#resolveloadermoduleextensions

raw-loader, A loader for webpack that allows importing files as a String. By default, raw-​loader generates JS modules that use the ES modules syntax. I had a similar problem, but with PDF instead of text files, and file-loader instead of raw-loader. I followed @danman113's awesome post, and it almost worked - turns out the PDF was being double-processed - once by the webpack config, and once by the !file-loader directive. It worked once I added a 'pdf' exclusion to this part of webpack


You have an error in your regexp pattern.

You are using \a which matches the bell character (ASCII 7)

And . matches any character, you need to escape it.

Moreover, using both use and loader is misleading. You should use only one - see this answer: When do I use 'use' and 'loader' in Webpack 2 module.rules?

Try to use:

module.exports = {
  module: {
    rules: [
      {
        test: /app\.js$/i,
        loader: 'raw-loader'
      }
    ]
  }
}

raw-loader, It's just this simple import pauseIcon from '!!raw!../../theme/images/pause.svg'; And I got this [piping] error given was: Error: Cannot find module  I'm creating an npm module library to be used in a separate project that includes that module. So I've been building the module - it creates a bundle.js and a separate worker file with it in the build directory - then I run the project, and I don't get any errors, but it doesn't seem like the Worker is actually doing anything/receiving my messages.


Firstly I would update webpack. The version that you are using is, currently, 2 major versions behind the latest release. Maybe the error messages have been improved! Also, you can see more info about the error running webpack --display-error-details.

Cannot use raw loader module for webpack · Issue #1197 · erikras , Get the following error after running webpack. ERROR in [at-loader] ./src/index.ts:​3:17 TS2307: Cannot find module './simple.txt'. webpack is a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser, yet it is also capable of transforming, bundling, or packaging just about any resource or asset.


Cannot import file using typescript · Issue #56 · webpack-contrib/raw , Build error: Cannot find module '!raw-loader!../public/styles.css' #104 find module '!raw-loader!../public/styles.css' at webpackMissingModule  esModule. Type: Boolean Default: true By default, raw-loader generates JS modules that use the ES modules syntax. There are some cases in which using ES modules is beneficial, like in the case of module concatenation and tree shaking.


Build error: Cannot find module '!raw-loader!../public/styles , Describe the bug Error: Cannot find module 'raw-loader' To Reproduce Install (​internal/modules/cjs/helpers.js:30:19)\n at Object.webpack  Operating System: Windows 7 Node Version: 11.13.0 NPM Version: 6.7.0 webpack Version: webpack included in Angular 7.2.11/ Angular CLI 7.3.7 raw-loader Version: 2.0.0 Expected Behavior I expect raw-loader uses to properly read the text co


raw-loader module not found when using with Angular 8, breaks , js Module not found: Error: Cannot resolve module 'fs' in C:\GitHub\CryptoPrices\​node_modules\file-exists # ./~/file-exists/index.js 3:9-22 file-exists uses fs as a  Webpack version 1.13.2 Node and npm version did not change on the server though. This stopped working only recently so I don't think downgrading the npm version would help us.