webpack执行npx webpack报错

报错信息

npm ERR! code ENOLOCAL
npm ERR! Could not install from "Files\nodejs\node_cache\_npx\11132" as it does not contain a package.json file.

npm ERR! A complete log of this run can be found in:
npm ERR!     F:\Program Files\nodejs\node_cache\_logs\2018-09-23T07_00_39_694Z-debug.log
Install for prefix@latest failed with code 1
G:\web\webpack-demo\node_modules\webpack\bin\webpack.js

Insufficient number of arguments or no entry found.
Alternatively, run 'webpack(-cli) --help' for usage info.

Hash: b38c9f3f5e57c0e3f3c3
Version: webpack 4.19.1
Time: 51ms
Built at: 2018-09-23 15:00:40

WARNING in configuration
The 'mode' option has not been set, webpack will fallback to 'production' for this value. Set 'mode' option to 'development' or 'production' to enable defaults for each environment.
You can also set it to 'none' to disable any default behavior. Learn more: https://webpack.js.org/concepts/mode/

ERROR in Entry module not found: SyntaxError: G:\web\webpack-demo\package.json (directory description file): SyntaxError: Unexpected token / in JSON at position 73

原因

package.json文件语法错误
我是在最后一项配置后多了一个逗号

{
  "name": "webpack-demo",
  "version": "1.0.0",
  "description": "",
  "private": true,
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "webpack": "^4.19.1",
    "webpack-cli": "^3.1.0"
  },//这里的逗号导致语法错误
}

解决

按照报错信息指示的位置检查语法

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/wq18512847606/article/details/82822454
今日推荐