请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

npm start时报错,提示如下

图片描述npm start报错

/* .babelrc */
{
  "presets": [
    ["latest", {
      "es2015": {
        "modules": false
      }
    }]
  ],
  "plugins": ["external-helpers"]
}

/* rollup.config.js */
import babel from 'rollup-plugin-babel'
import resolve from 'rollup-plugin-node-resolve'

export default {
  entry: './src/index.js',
  format: 'umd',
  plugins: [
    resolve(),
    babel({
      exclude: 'node_modules/**'
    })
  ],
  dest: './build/bundle.js'
}

/* package.json */
{
  "name": "rollup-cj",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "rollup -c rollup.config.js"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "babel-core": "^6.26.3",
    "babel-plugin-external-helpers": "^6.22.0",
    "babel-preset-latest": "^6.24.1",
    "rollup": "^0.66.6",
    "rollup-plugin-babel": "^4.0.3",
    "rollup-plugin-node-resolve": "^3.4.0"
  }
}

正在回答 回答被采纳积分+3

3回答

提问者 negrochn 2018-10-26 15:10:09

问题已解决,"rollup-plugin-babel": "^4.0.3",此版本问题,执行npm install --save-dev rollup-plugin-babel@3即可

1 回复 有任何疑惑可以回复我~
慕桂英5446361 2018-11-30 16:54:22

我的也报错 按照你的 配置文件来就可以了

{
  "name": "rollup-cj",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "rollup -c rollup.config.js",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "babel-core": "^6.26.3",
    "babel-plugin-external-helpers": "^6.22.0",
    "babel-preset-latest": "^6.24.1",
    "rollup": "^0.66.6",
    "rollup-plugin-babel": "^3.0.7",
    "rollup-plugin-node-resolve": "^3.4.0"
  }
}


0 回复 有任何疑惑可以回复我~
双越 2018-10-24 10:41:45

运行 npm install --save-dev babel-core 试一下 

0 回复 有任何疑惑可以回复我~
  • 提问者 negrochn #1
    试过的,package.json中已经有了babel-core,但还是报这个错
    回复 有任何疑惑可以回复我~ 2018-10-25 08:41:46
  • 双越 回复 提问者 negrochn #2
    重新安装下 babel 试试吧。目前这种 npm 插件版本不一致的问题,比较蛋疼。
    回复 有任何疑惑可以回复我~ 2018-10-25 10:10:04
  • 提问者 negrochn 回复 双越 #3
    找到原因了,rollup-plugin-babel默认版本为4,使用以下版本就ok了
    
    {
      "name": "rollup-cj",
      "version": "1.0.0",
      "description": "",
      "main": "index.js",
      "scripts": {
        "start": "rollup -c rollup.config.js",
        "test": "echo \"Error: no test specified\" && exit 1"
      },
      "author": "",
      "license": "ISC",
      "devDependencies": {
        "babel-core": "^6.26.3",
        "babel-plugin-external-helpers": "^6.22.0",
        "babel-preset-latest": "^6.24.1",
        "rollup": "^0.66.6",
        "rollup-plugin-babel": "^3.0.7",
        "rollup-plugin-node-resolve": "^3.4.0"
      }
    }
    回复 有任何疑惑可以回复我~ 2018-10-25 20:52:18
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信