Node-restify: restify.acceptParser is not a function;

Created on 16 Sep 2016  路  9Comments  路  Source: restify/node-restify

server.use(restify.acceptParser(server.acceptable));
^

TypeError: restify.acceptParser is not a function
at Object. (C:\Ash\NJS\node_api\app.js:7:20)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Function.Module.runMain (module.js:441:10)
at startup (node.js:139:18)
at node.js:974:3

Guys,

After spending 4 hours , I realized the plugins were moved out. I wish this was updated at

http://restify.com/#bundled-plugins

Bundled Plugins

restify ships with several handlers you can use, specifically:

Accept header parsing
Authorization header parsing
CORS handling plugin

I can do it, if someone tells me how.

need to add in the installation section

npm install restify
npm install restify-plugins

//Code

var restify = require('restify');
var plugins = require('restify-plugins')
var server = restify.createServer();

server.use(plugins .acceptParser(server.acceptable));
server.use(plugins .bodyParser());

thanks,
-ash

Most helpful comment

server.use(restify.plugins.acceptParser(server.acceptable));

All 9 comments

Apologies, we published a beta version of 5.x, but failed to tag it as pre-release so it automatically got pulled in when running npm install restify. We have since pointed latest back at 4.1.1 and you shouldn't see these type of issues any longer.

Prior to publishing Restify 5 for real, we'll be updating our docs as well as formalizing our 4.x to 5.x migration guide which will call at these type of backwards breaking changes.

We do apologize for the inconvenience and confusion.

no problem and thanks for helping other users not go through the same problem.
and great work otherwise.

Already back to 4.1.1, it work!

it's solved? is any solution?

@lmyzzu
you can run this command:

npm i --save [email protected]

or use the restify-plugins

The issue is still in 5.2.0 (and I don't see anything in the doc)

Apologies - I haven't been keeping tabs on closed threads. The plugins in 5.x are all located on restify.plugins, including the acceptParser. If you are having issues, I would highly recommend filing a new issue. Thank you!

@DonutEspresso Any example? It is not a problem as long as we know how to replace the code.

server.use(restify.plugins.acceptParser(server.acceptable));

Was this page helpful?
0 / 5 - 0 ratings