npm start时报错,提示如下

来源:2-7 模块化 - rollup安装

negrochn

2018-10-23

图片描述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回答

negrochn

提问者

2018-10-26

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

1
0

慕桂英5446361

2018-11-30

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

{
  "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
0

双越

2018-10-24

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

0
3
negrochn
回复
双越
找到原因了,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
共3条回复

前端跳槽必备 一线互联网公司高级前端JavaScript面试

视频讲解前端面试中的JS高级知识点,扩展JS知识深度,从容面试

1621 学习 · 218 问题

查看课程