@rollup/plugin-node-resolve throws error: Cannot read property 'length' of undefined

Viewed 840

I got this error and it comes from @rollup/plugin-node-resolve

[!] TypeError: Cannot read property 'length' of undefined
TypeError: Cannot read property 'length' of undefined
//...
at async Promise.all (index 0)
at async Promise.all (index 2)
at async Promise.all (index 0)
at async Promise.all (index 0)
at async Promise.all (index 0)

This is my config. I can confirm the error is coming from @rollup/plugin-node-resolve

const config = {
  input: './build/sw.js',
  //Other configs
  }],
  plugins: [
    nodeResolve(),
    commonjs({
      include: ['./src/**', 'node_modules/**']
    })
  ]
}

I am importing the following workbox dependency in my sw.js

workbox-core

workbox-precaching

workbox-routing

workbox-strategies

workbox-expiration

workbox-background-sync

How can I tackle this error?

1 Answers

Not 100% sure about the cause of this issue, but I found out that if I dont explicitly install Rollup in my packages, the version of Rollup you would get with npx rollup -v is 1.x.x. Upgrading it to 2.x.x would fix this error.

Related