Skip to content

ng build not working with dependency to npm module csvtojson #10694

@toedter

Description

@toedter

Versions

Angular CLI: 6.0.0                                              
Node: 8.11.1                                                    
OS: win32 x64 (Windows 10)                                                  
Angular: 6.0.0                                                  
... animations, cli, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser                    
... platform-browser-dynamic, router                            
                                                                
Package                           Version                       
-----------------------------------------------------------     
@angular-devkit/architect         0.6.0                         
@angular-devkit/build-angular     0.6.0                         
@angular-devkit/build-optimizer   0.6.0                         
@angular-devkit/core              0.6.0                         
@angular-devkit/schematics        0.6.0                         
@ngtools/webpack                  6.0.0                         
@schematics/angular               0.6.0                         
@schematics/update                0.6.0                         
rxjs                              6.1.0                         
typescript                        2.7.2                         
webpack                           4.6.0                         

Repro steps

  • Install CLI 6.0.0
  • Create new project
  • add csvtojson and @types/csvtojson to package.json and run npm install
  • add the following code to app.component.ts, so that it looks like
import {Component} from '@angular/core';
import {Converter} from 'csvtojson';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  title = 'app';

  constructor() {
    const converter = new Converter({delimiter: ';', trim: true});
    converter.fromString('1,2,3');
  }
}

Observed behavior

When running ng build, the output is

Date: 2018-05-07T11:19:06.866Z
Hash: efcc2624f253b7b09016
Time: 15011ms
chunk {main} main.js, main.js.map (main) 10.4 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 226 kB [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 5.4 kB [entry] [rendered]
chunk {styles} styles.js, styles.js.map (styles) 15.6 kB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 3.73 MB [initial] [rendered]

ERROR in ./node_modules/csvtojson/libs/interfaces/web/webServer.js
Module not found: Error: Can't resolve 'http' in 'D:\temp\cli-test\node_modules\csvtojson\libs\interfaces\web'
ERROR in ./node_modules/csvtojson/libs/core/Converter.js
Module not found: Error: Can't resolve 'os' in 'D:\temp\cli-test\node_modules\csvtojson\libs\core'
ERROR in ./node_modules/csvtojson/libs/core/getEol.js
Module not found: Error: Can't resolve 'os' in 'D:\temp\cli-test\node_modules\csvtojson\libs\core'
ERROR in ./node_modules/csvtojson/libs/core/Converter.js
Module not found: Error: Can't resolve 'stream' in 'D:\temp\cli-test\node_modules\csvtojson\libs\core'
ERROR in ./node_modules/first-chunk-stream/index.js
Module not found: Error: Can't resolve 'stream' in 'D:\temp\cli-test\node_modules\first-chunk-stream'

Desired behavior

It should build without error, as it did with Angular CLI 1.7.4

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions