当我在Power Shell命令“ webpack”中构建前端时,出现此错误。全局Webpack版本“ 4.22.0”(下面的命令)。本地Webpack版本“ 4.20.2”。
PS D:\ThePlatform\View.WebInterface> npm info webpack version
4.22.0
PS D:\ThePlatform\View.WebInterface> webpack
C:\Users\user\AppData\Roaming\npm\node_modules\webpack-cli\bin\config-yargs.js:89
describe: optionsSchema.definitions.output.properties.path.description,
^
TypeError: Cannot read property 'properties' of undefined
at module.exports (C:\Users\Nikita\AppData\Roaming\npm\node_modules\webpack-cli\bin\config-yargs.js:89:48)
at C:\Users\Nikita\AppData\Roaming\npm\node_modules\webpack-cli\bin\webpack.js:60:27
at Object.<anonymous> (C:\Users\Nikita\AppData\Roaming\npm\node_modules\webpack-cli\bin\webpack.js:515:3)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
package.json的一部分
"webpack": "4.20.2",
"webpack-cli": "3.1.2",
文件webpack.config.js的一部分
module.exports = {
entry: ['./App/System/app.ts', './App/System/scss/' + account + '.scss'],
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'App/Dist'),
},
resolve: {
modules: [
process.env.NODE_PATH || 'node_modules',
],
extensions: ['.ts', '.js', '.html']
},
module: {
rules: [
{
test: /\.ts$/,
loaders: [
{
loader: 'awesome-typescript-loader',
options: { configFileName: path.resolve(__dirname, 'tsconfig.json') }
}, 'angular2-template-loader'
]
},
{
test: /\.html$/,
loader: 'html-loader'
},
{
enforce: 'pre',
test: /\.ts$/,
use: "source-map-loader"
},
{
test: /\.s?[ac]ss$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
'sass-loader',
],
},
// { test: /\.css$/, loader: 'style-loader!css-loader' },
]
},
}
当我将Webpack从4.8.3版本更新到4.20.2时出现此问题
答案 0 :(得分:1)
npm install webpack
将其安装在本地目录中。通常,您的PATH
中没有这个功能,因此您很有可能执行webpack
全局安装的npm install -g
。
尝试通过以下方式升级全局安装的webpack
:
npm upgrade -g webpack
或者,您可以将本地安装的webpack
用于:
`npm bin`/webpack --version
或者:
PATH=`npm bin`:$PATH webpack --version