Webpack安装问题

时间:2017-12-10 11:05:09

标签: javascript npm webpack installation

我想用npm设置webpack和babel,但是我收到了这个错误

npm ERR! Unexpected end of JSON input while parsing near '...pdragon":"^0.7.0","to' npm ERR! A complete log of this run can be found in:
npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\luchan.vladyslav\AppData\Roaming\npm-cache\_logs\2017-12-10T10_48_56_298Z-debug.log

这是我的package.json

{
  "name": "ddd",
  "version": "1.0.0",
  "description": "components",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "babel-core": "^6.26.0",
    "babel-loader": "^7.1.2",
    "babel-preset-env": "^1.6.1"
  }
}

开始时我尝试在一行中安装webpack webpack-dev-server babel-core babel-loader和babel-preset-env。但是我得到了这个错误,过了一段时间我发现问题与webpack和wepback-dev-server相关

screenshot

2 个答案:

答案 0 :(得分:0)

看起来要归咎于损坏的本地node_modules。你可以删除本地node_modules文件夹,然后通过`npm install'重新安装吗?这应该可以解决问题。

答案 1 :(得分:0)

要解决此问题,您应该使用

清理缓存
npm cache clean --force

这将解决问题