N
N
Nikita2021-04-07 15:57:52
webpack
Nikita, 2021-04-07 15:57:52

How to solve the webpack build issue “This is probably not a problem with npm. There is likely additional logging output above."?

// webpack.config.js

const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const TsconfigPathsPlugin = require("tsconfig-paths-webpack-plugin");
const webpack = require("webpack")

const isDev = process.env.WEBPACK_MODE === "development";
const isProd = !isDev;

module.exports = {
  entry: "./src/index.tsx",
  output: {
    filename: "script.js",
    path: path.join(__dirname, "dist"),
    publicPath: "/",
  },
  plugins: [
    new TsconfigPathsPlugin({ configFile: "./tsconfig.json" }),
    new MiniCssExtractPlugin(),
    new HtmlWebpackPlugin({
        template: './src/index.html',
        minify: isProd
    }),
    new webpack.ProvidePlugin({
        process: 'process/browser',
      }),
    new CleanWebpackPlugin()
  ],
  resolve: {
    extensions: [".js", ".ts", ".tsx"],
    fallback: { 
        crypto: require.resolve("crypto-browserify"),
        "stream": require.resolve("stream-browserify")
    },
    alias: {
        process: "process/browser"
    }
  },
  devServer: {
    port: 3000,
    hot: isDev,
    historyApiFallback: true,
  },
  // optimization: optimization(),
  module: {
    rules: [
      {
        test: /\.(js|tsx?)$/,
        exclude: [/node_modules/],
        use: {
          loader: "ts-loader",
        },
      },
      {
        test: /\.css/,
        exclude: [/node_modules/],
        use: [MiniCssExtractPlugin.loader, "css-loader"],
      },
    ],
  },
};

Build error log:
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs \\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'run',
1 verbose cli 'build'
1 verbose cli ]
2 info using [email protected]
3 info using [email protected] 15.4
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle [email protected]~prebuild: [email protected]
6 info lifecycle [email protected]~build: [email protected] 1
7 verbose lifecycle [email protected]~build: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]~build: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\mirot\Documents\projects\merge\ 1\2\node_modules\.bin;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Razer Chroma SDK\bin;C:\Program Files\Razer Chroma SDK\bin;C:\ Program Files (x86)\Razer\ChromaBroadcast\bin;C:\Program Files\Razer\ChromaBroadcast\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\ System32\WindowsPowerShell\v1.0\;C:\Program Files\nodejs\;C:\Program Files\Git\cmd;C:\Windows\system32\config\systemprofile\AppData\Local\Microsoft\WindowsApps;C:\ Program Files\dotnet\;C:\Users\mirot\AppData\Local\Microsoft\WindowsApps;;C:\Users\mirot\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\mirot\AppData\ Roaming\npm;C:\Users\mirot\.dotnet\tools
9 verbose lifecycle [email protected]~build: CWD: C:\Users\mirot\Documents\projects\merge\1\2
10 silly lifecycle [email protected]~build: Args: [
10 silly lifecycle '/d / s /c',
10 silly lifecycle 'cross-env WEBPACK_MODE=production webpack --mode production'
10 silly lifecycle ]
11 silly lifecycle [email protected]~build: Returned: code: 1 signal: null
12 info lifecycle [email protected] .1~build: Failed to exec build script
13 verbose stack Error: [email protected] build: `cross-env WEBPACK_MODE=production webpack --mode production`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter. (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
13 verbose stack at EventEmitter.emit(events.js:315:20)
13 verbose stack at ChildProcess. (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:315:20)
13 verbose stack at maybeClose (internal/child_process.js:1048:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
14 verbose pkgid [email protected]
15 verbose cwd C:\Users\mirot \Documents\projects\merge\1\2
16 verbose Windows_NT 10.0.19042
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\ npm\\bin\\npm-cli.js" "run" "build"
18 verbose node v14.15.4
19 verbose npm v6.14.10
20 error code ELIFECYCLE
21 error errno 1
22 error [email protected] build: `cross-env WEBPACK_MODE=production webpack --mode production`
22 error Exit status 1
23 error Failed at the [email protected] 1 buildscript.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question