pjlamb12
pjlamb12

Reputation: 2422

Error: TypeError: "listener" argument must be a function in Node 7.7.2

I've been upgrading a project of mine to Node 7.7.2. The project has a whole bunch of calls to APIs and databases etc. When I try and run the project,

TypeError: "listener" argument must be a function
    at Socket.once (events.js:307:11)
    at Socket.connect (net.js:943:10)
    at Connection.connectOnPort ([path]/testing/mssql/node_modules/tedious/lib/connection.js:429:19)
    at Connection.connect ([path]/testing/mssql/node_modules/tedious/lib/connection.js:402:21)
    at Connection.initialiseConnection ([path]/testing/mssql/node_modules/tedious/lib/connection.js:77:12)
    at Connection.enter ([path]/testing/mssql/node_modules/tedious/lib/connection.js:975:19)
    at Connection.transitionTo ([path]/testing/mssql/node_modules/tedious/lib/connection.js:508:33)
    at new Connection ([path]/testing/mssql/node_modules/tedious/lib/connection.js:66:10)
    at Object.cfg_pool.create ([path]/testing/mssql/node_modules/mssql/lib/tedious.js:375:19)
    at Pool._createResource ([path]/testing/mssql/node_modules/generic-pool/lib/generic-pool.js:354:17)

However, when I run the exact same code using Node 7.7.1, I don't get the error and the response comes back as expected. I've searched the error for a couple days now; but I don't know if it's just a generic enough error that I haven't really been able to find anything specific to Node 7.7.2. I found one thing, and that's what pointed me to trying it with 7.7.1. Any help would be greatly appreciated!

Upvotes: 2

Views: 1100

Answers (1)

doublesharp
doublesharp

Reputation: 27599

I used nvm from http://nvm.sh to select 7.7.1 on my CentOS system (it had auto-updated via yum-cron). See the link to install on different operating systems.

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.1/install.sh | bash
nvm install 7.7.1
nvm use 7.7.1
node -v

Output:

v7.7.1

I happen to be using PM2 to run my app and ended up having to use a JSON file to define the entry and specify the Node version. Note that this feature of PM2 requires NVM.

app.json

{ 
  "apps": [{
    "name": "MyApp",
    "script": "script.js",
    "interpreter": "[email protected]"
 }]
}

You can launch this process file from PM2 like so

pm2 start ./app.json

Upvotes: 4

Related Questions