Error: Cannot read property 'buffer' of undefined


I start a new app by following these steps:

  1. ionic start myApp
  2. cd myApp & ionic setup sass
  3. ionic platform add ios
  4. ionic build ios

I always get the error as in the title:

Error: Cannot read property ‘buffer’ of undefined

What was wrong? And I don’t see platforms/ folder under my root directory.


Got the same error when running ionic serve.
In my console it says:

rollup: No name was provided for external module 'buffer' in options.globals – guessing 'buffer'```

And then I get the ``Error: Cannot read property 'buffer' of undefined`` in my JS console.

Running Ionic 2 RC.0.
Created a new ionic app using ionic startapp and moved&converted my old beta.11 code to the new project.
Must has something to do with a missing dependency I guess, but it's hard to track down which one exactly


For me, the issue was caused by the latest version of angular2-jwt (v0.1.19).
This imports Base64 from js-base64, which uses ‘buffer’.

I’ve downgraded angular2-jwt to the version I used prior to upgrading my Ionic project to RC.0, and now, with version 0.1.12, js-base64 is not used and I don’t get the error anymore.

But need to find a better solution.
Is this a dependency problem in angular2-jwt (which doesnt play well with angular or ionic?) or do I need to do some extra configuration for Rollup?


I am actually also experiencing this exact same issue.

Have you come any closer to a proper solution? It is a really annoying problem.


No, for me this solution works for now. There are some more issues which I need to solve first.
Also I red that Ionic might change their default build script to Webpack, so I’ll wait for the final release before I dive into these specific import issues.


Yes I read that too. I move back to webpack should solve the problem.

I also decided to just roll back to the previous version of angular2-jwt


I fixed my angular2-jwt build by following the upgrade to 2.0.0-rc.1 and adding the types for js-base64:

Cannot find module ‘js-base64’

npm install @types/js-base64 --save