Monday, December 11, 2017

TypeError: csv is not a function in Nodejs

I am getting the following error in Nodejs, when I use a csv module.

TypeError: csv is not a function
    at Object.<anonymous> (/root/app.js:4:11)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:383:7)
    at startup (bootstrap_node.js:149:9)
    at bootstrap_node.js:496:3


Here is my npm list:
[root@machine2 ~]# npm list
root@1.0.0 /root
├── csv@2.0.0 extraneous
└─┬ debug@3.1.0
  └── ms@2.0.0

 
Solution for this issue:
You need to remove the curret csv module and need to instll csv@0.3.7 which will solve this issue. Below given steps will surely help you.
 
[root@machine2 ~]# npm remove csv
- lodash.get@4.4.2 node_modules/lodash.get
- csv-generate@2.0.0 node_modules/csv-generate
- csv-parse@2.0.0 node_modules/csv-parse
- csv-stringify@2.0.0 node_modules/csv-stringify
- stream-transform@1.0.0 node_modules/stream-transform
- csv@2.0.0 node_modules/csv
npm WARN root@1.0.0 No description
npm WARN root@1.0.0 No repository field.
 

[root@machine2 ~]# npm list
root@1.0.0 /root
└─┬ debug@3.1.0
  └── ms@2.0.0

[root@machine2 ~]# npm install csv@0.3.7
root@1.0.0 /root
└── csv@0.3.7
npm WARN root@1.0.0 No description
npm WARN root@1.0.0 No repository field.
[root@machine2 ~]#


It works!
 

No comments:

Post a Comment