npm Webpack code ELIFECYCLE errno 1

When building the PiCockpit frontend code (which is packaged using Webpack) on a different computer, I ran into the following issue:

cross-env NODE_ENV=production webpack –progress –hide-modules –mode=production
type: ‘object’,
additionalProperties: true,
properties: {
apply: {
description: ‘The run point of the plugin, required method.’,
instanceof: ‘Function’,
tsType: “(compiler: import(‘../lib/Compiler’)) => void”
}
},
required: [ ‘apply’ ]
}
},
title: ‘WebpackOptions’,
description: ‘Options object as provided by the user.’,
type: ‘object’,
additionalProperties: false,
properties: {
amd: { ‘$ref’: ‘#/definitions/Amd’ },
bail: { ‘$ref’: ‘#/definitions/Bail’ },
cache: { ‘$ref’: ‘#/definitions/CacheOptions’ },
context: { ‘$ref’: ‘#/definitions/Context’ },
dependencies: { ‘$ref’: ‘#/definitions/Dependencies’ },
devServer: { ‘$ref’: ‘#/definitions/DevServer’ },
devtool: { ‘$ref’: ‘#/definitions/DevTool’ },
entry: { ‘$ref’: ‘#/definitions/Entry’ },
experiments: { ‘$ref’: ‘#/definitions/Experiments’ },
externals: { ‘$ref’: ‘#/definitions/Externals’ },
externalsPresets: { ‘$ref’: ‘#/definitions/ExternalsPresets’ },
externalsType: { ‘$ref’: ‘#/definitions/ExternalsType’ },
ignoreWarnings: { ‘$ref’: ‘#/definitions/IgnoreWarnings’ },
infrastructureLogging: { ‘$ref’: ‘#/definitions/InfrastructureLogging’ },
loader: { ‘$ref’: ‘#/definitions/Loader’ },
mode: { ‘$ref’: ‘#/definitions/Mode’ },
module: { ‘$ref’: ‘#/definitions/ModuleOptions’ },
name: { ‘$ref’: ‘#/definitions/Name’ },
node: { ‘$ref’: ‘#/definitions/Node’ },
optimization: { ‘$ref’: ‘#/definitions/Optimization’ },
output: { ‘$ref’: ‘#/definitions/Output’ },
parallelism: { ‘$ref’: ‘#/definitions/Parallelism’ },
performance: { ‘$ref’: ‘#/definitions/Performance’ },
plugins: { ‘$ref’: ‘#/definitions/Plugins’ },
profile: { ‘$ref’: ‘#/definitions/Profile’ },
recordsInputPath: { ‘$ref’: ‘#/definitions/RecordsInputPath’ },
recordsOutputPath: { ‘$ref’: ‘#/definitions/RecordsOutputPath’ },
recordsPath: { ‘$ref’: ‘#/definitions/RecordsPath’ },
resolve: { ‘$ref’: ‘#/definitions/Resolve’ },
resolveLoader: { ‘$ref’: ‘#/definitions/ResolveLoader’ },
snapshot: { ‘$ref’: ‘#/definitions/SnapshotOptions’ },
stats: { ‘$ref’: ‘#/definitions/StatsValue’ },
target: { ‘$ref’: ‘#/definitions/Target’ },
watch: { ‘$ref’: ‘#/definitions/Watch’ },
watchOptions: { ‘$ref’: ‘#/definitions/WatchOptions’ }
}
},
headerName: ‘Webpack’,
baseDataPath: ‘configuration’,
postFormatter: [Function: postFormatter]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: cross-env NODE_ENV=production webpack --progress --hide-modules --mode=production
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\…\AppData\Roaming\npm-cache_logs\2022-05-12T15_01_47_281Z-debug.log

Fixes

The typical suggestion online to fix this error is to remove node_modules, to remove package-lock.json and to reinstall the modules using npm install.

This did not work for me, the error persisted.

Here is what worked:

I looked at webpack.config.js and disabled parts of it, until I had my culprit. The two following lines had to be commented out, to make the configuration work:

// devtool: ‘#eval-source-map’,

// module.exports.devtool = ‘#source-map’

It might be different in your case – I recommend to try and experiment with webpack.config.js as necessary.