npm run test报错
"webpack": "^4.41.0","webpack-cli": "^3.3.9","webpack-dev-server": "^3.8.1""copy-webpack-plugin": "^5.0.4",package.json中的test:"scripts": {"test": "npx webpack-dev-server --config webpack.config.js"},报
·
"webpack": "^4.41.0",
"webpack-cli": "^3.3.9",
"webpack-dev-server": "^3.8.1"
"copy-webpack-plugin": "^5.0.4",
package.json中的test:
"scripts": {
"test": "npx webpack-dev-server --config webpack.config.js"
},
报错:
PS D:\Project\WebStudy\zhiboyu\webpack\24_webpack_dev_server> npm run test
Debugger attached.
> 01-webpack-introductory@1.0.0 test D:\Project\WebStudy\zhiboyu\webpack\24_webpack_dev_server
> npx webpack-dev-server --config webpack.config.js
Debugger attached.
Debugger attached.
Waiting for the debugger to disconnect...
D:\Project\WebStudy\zhiboyu\webpack\24_webpack_dev_server\node_modules\schema-utils\src\validateOptions.js:32
throw new ValidationError(ajv.errors, name);
^
ValidationError: CopyPlugin Invalid Options
options should be array
at validateOptions (D:\Project\WebStudy\zhiboyu\webpack\24_webpack_dev_server\node_modules\schema-utils\src\validateOptions.js:32:11)
at new CopyPlugin (D:\Project\WebStudy\zhiboyu\webpack\24_webpack_dev_server\node_modules\copy-webpack-plugin\dist\index.js:26:30)
at Object.<anonymous> (D:\Project\WebStudy\zhiboyu\webpack\24_webpack_dev_server\webpack.config.js:120:9)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at WEBPACK_OPTIONS (D:\Project\WebStudy\zhiboyu\webpack\24_webpack_dev_server\node_modules\webpack-cli\bin\utils\convert-argv.js:114:13)
at requireConfig (D:\Project\WebStudy\zhiboyu\webpack\24_webpack_dev_server\node_modules\webpack-cli\bin\utils\convert-argv.js:116:6)
at D:\Project\WebStudy\zhiboyu\webpack\24_webpack_dev_server\node_modules\webpack-cli\bin\utils\convert-argv.js:123:17
at Array.forEach (<anonymous>)
at module.exports (D:\Project\WebStudy\zhiboyu\webpack\24_webpack_dev_server\node_modules\webpack-cli\bin\utils\convert-argv.js:121:15)
at Object.<anonymous> (D:\Project\WebStudy\zhiboyu\webpack\24_webpack_dev_server\node_modules\webpack-dev-server\bin\webpack-dev-server.js:84:40)
at Module._compile (internal/modules/cjs/loader.js:1063:30) {
errors: [
{
keyword: 'type',
dataPath: '',
schemaPath: '#/type',
params: { type: 'array' },
message: 'should be array'
}
]
}
Waiting for the debugger to disconnect...
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! 01-webpack-introductory@1.0.0 test: `npx webpack-dev-server --config webpack.config.js`npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the 01-webpack-introductory@1.0.0 test 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\kirin\AppData\Roaming\npm-cache\_logs\2021-05-21T07_51_47_749Z-debug.log
Waiting for the debugger to disconnect...
其中主要是这里(webpack.config.js出错):
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! 01-webpack-introductory@1.0.0 test: `npx webpack-dev-server --config webpack.config.js`npm ERR! Exit status 1
解决:
在webpack.config.js中下面这一段出错:
new CopyWebpackPlugin(
{
patterns:
[{ from: "./doc", to: "doc" }]
}
),
修改为:
new CopyWebpackPlugin(
[{ from: "./doc", to: "doc" }]
),
然后就跑成功了,
更多推荐
所有评论(0)