rollup/rollup-plugin-node-resolve

rollup-plugin-json is required with { browser: true }

akvadrako opened this issue · 5 comments

I just started using rollup for a new project and had a lot of trouble tracking down the cause of a confusing error message. Apparently, rollup-plugin-json is required when using browser: true, otherwise I get this error:

$ node_modules/.bin/rollup -c

src/index.js → dist/bundle.js...
[!] Error: Unexpected token
node_modules/websocket/package.json (2:8)
1: {
2:   "name": "websocket",
           ^
3:   "description": "Websocket Client & Server Library implementing the WebSocket protocol as specified in RFC 6455.",
4:   "keywords": [

Hey @akvadrako thanks for the issue.

Have you tried the latest version of rollup-plugin-node-resolve? I think it may fix this for you.

I have the same issue, but with or without rollup-plugin-json using "rollup-plugin-node-resolve": "^3.0.3"

echo :

[!] Error: Unexpected token
node_modules/web3/lerna.json (2:11)
1: {
2:   "version": "1.0.0-beta2",
              ^
3:   "lerna": "2.0.0",
4:   "packages": [

1
npm ERR! code ELIFECYCLE
npm ERR! errno 1

Same issue here! Using version 3.3.0.

My config:

import resolve from 'rollup-plugin-node-resolve'
import commonjs from 'rollup-plugin-commonjs'

export default {
  input: 'src/index.ts',
  output: {
    file: 'lib/index.js',
    format: 'cjs'
  },
  plugins: [
    resolve(),
    commonjs({
      include: 'node_modules/**'
    })
  ]
}

Error:

src/index.js → lib/index.js...
[!] Error: Unexpected token
node_modules/mongoose/package.json (2:8)
1: {
2:   "name": "mongoose",
           ^
3:   "description": "Mongoose MongoDB ODM",
4:   "version": "5.0.15",

I was having this problem as well, but then I converted my usage from the cli rollup command + a config file, to writing a js file which uses the rollup JS api, and then it worked! 🤷‍♂️

It can be closed for now. Some packages really need rollup-plugin-json. But, if an error happened, rollup will offer to install rollup-plugin-json

Can be closed now