Unity Hour
Unity Hour

Reputation: 570

Webpack looking for loaders in the wrong directory?

I am running webpack from webpack-stream. Consider the following code

gulp.task("scripts", () => {
  return gulp
    .src("./app/assets/scripts/App.js")
    .pipe(
      gulpWebpack(
        {
          output: {
            filename: "bundle.js"
          },

          module: {
            rules: [
              {
                test: /\.(js|jsx)$/,
                exclude: /(node_modules)/,
                loader: "babel-loader",
                query: {
                  presets: [["latest", { modules: false }]]
                }
              }
            ]
          }
        },
        webpack
      )
    )
    .pipe(gulp.dest("./app/temp/scripts"));
});

It gives the following error:-

Module build failed (from ./node_modules/babel-loader/lib/index.js):
(SystemJS) ENOENT: no such file or directory, open 'D:\@Udemy Courses\Git A Web Developer Job\course\D:\@Udemy Courses\Git A Web Developer Job\course\node_modules\babel-loader\lib\index.js'
        Error: ENOENT: no such file or directory, open 'D:\@Udemy Courses\Git A Web Developer Job\course\D:\@Udemy Courses\Git A Web Developer Job\course\node_modules\babel-loader\lib\index.js'
        Error loading D:/@Udemy Courses/Git A Web Developer Job/course/D:\@Udemy Courses\Git A Web Developer Job\course\node_modules\babel-loader\lib\index.js

If you closely observe the path in error code , you can see it is being repeated two times. For example

D:/course

is showing as

D:/course/D:/course/node_modules

How can I fix this?

Upvotes: 1

Views: 110

Answers (0)

Related Questions