akveo / ng2-smart-table

Angular Smart Data Table component
https://akveo.github.io/ng2-smart-table/
MIT License
1.63k stars 877 forks source link

Cannot find name 'Buffer'.) #207

Open st-clair-clarke opened 7 years ago

st-clair-clarke commented 7 years ago

Hi, I am running @angular.cli rc.0 and getting the following error with ng-serve


J:/workspace/angular2/ts/epimss/node_modules/ng2-smart-table/src/ng2-smart-table/lib/helpers.ts (3,20): Cannot find name 'Buffer'.)
J:/workspace/angular2/ts/epimss/node_modules/ng2-smart-table/src/ng2-smart-table/lib/helpers.ts (10,22): Cannot find name 'Buffer'.)
J:/workspace/angular2/ts/epimss/node_modules/ng2-smart-table/src/ng2-smart-table/lib/helpers.ts (11,17): Cannot find name 'Buffer'.)

in helpers (..\node_modules\ng2-smart-table\src\ng2-smart-table\lib\helpers.ts)s the Buffer has an assocated error of "Cannot find name 'Buffer'." 

Webstorm displays the following hints at correction:

![image](https://cloud.githubusercontent.com/assets/3227590/23519885/8cae6aea-ff46-11e6-9aa2-833a2c19f7b8.png)

How can I overcome this issue?

Thanks
kjetilhp commented 7 years ago

at least declare var Buffer: any; in typings.d.ts removes the error

PrazSam commented 7 years ago

I am running @angular.cli rc.1 and removed this error adding "types": ["node"] in to tsconfig.app.json

digaus commented 7 years ago
typescript: ...ttpTest/httpTest/node_modules/ng2-smart-table/src/ng2-smart-table/lib/helpers.ts, line: 3 
            Cannot find name 'Buffer'. 
       L2:  return (
       L3:    val instanceof Buffer
       L4:    || val instanceof Date
            Cannot find name 'Buffer'. 
       L9:  function cloneSpecificValue(val): any {
      L10:    if (val instanceof Buffer) {
      L11:      var x = new Buffer(val.length);
            Cannot find name 'Buffer'. 
      L10:  if (val instanceof Buffer) {
      L11:    var x = new Buffer(val.length);
      L12:    val.copy(x);
[08:55:46]  typescript: ...ttpTest/httpTest/node_modules/ng2-smart-table/src/ng2-smart-table/lib/helpers.ts, line: 10 
[08:55:46]  typescript: ...ttpTest/httpTest/node_modules/ng2-smart-table/src/ng2-smart-table/lib/helpers.ts, line: 11 
[08:55:46]  transpile failed 
[08:55:46]  ionic-app-script task: "build" 
[08:55:46]  Error: Error 

The fixes above did not work for me :/

daffodilistic commented 7 years ago

Hi @digaus,

The fix from @kjetilhp worked for me, you might want to check your configuration; I am running Node.JS v6.10 and npm v3.10.10.

If you're using the quickstart seed from the Angular project (the one with instructions to clone the GitHub repo), don't follow that, instead, follow the CLI Quickstart

digaus commented 7 years ago

I am trying to use it in an Ionic 2 project...

cordova CLI: 6.5.0
Ionic Framework Version: 2.1.0-201703061537
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.2.0
Ionic App Scripts Version: 1.1.4
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Windows 10
Node Version: v6.10.0
Xcode version: Not installed
fizdalf commented 7 years ago

I have the same issue, Running Angular CLI 1.0.0, node v7.2.0 and npm 4.4.4, there's no tsconfig.app.json but just tsconfig.json..have added that "types": ["node"] and didn't work, also added declare var Buffer: any; to typings.d.ts..and nothing...weird thing is that my IDE (Webstorm) does resolve Buffer.

lexzhukov commented 7 years ago

@fizdalf try to install the latest ng2-smart-table version npm i -S ng2-smart-table@latest.

PrazSam commented 7 years ago

@fizdalf tsconfig.app.json is in the same level of app directory. If you cannot find such file you haven't migrated your old code (cli beta generated) for rc versions and above ( as per my knowledge). If so please refer this guide for the ease of further developments.