var expressValidator = require('express-validator');
app.use(expressValidator({
errorFormatter: function(param, msg, value){
var namespace = param.split('.'),
root = namespace.shift(),
formParam = root;
while(namespace.length){formParam += '[' + namespace.shift() + ']';}
return{param: formParam, msg: msg, value: value};
}
}));
在终端上运行“ npm start”后,我得到:
> nodeauthorization@0.0.0 start /Users/username/Desktop/nodeauthorization
> node ./bin/www
/Users/username/Desktop/nodeauthorization/app.js:44
app.use(expressValidator({
^
TypeError: expressValidator is not a function
at Object.<anonymous>(/Users/username/Desktop/nodeauthorization/app.js:44:9)
at Module._compile (internal/modules/cjs/loader.js:945:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:962:10)
at Module.load (internal/modules/cjs/loader.js:798:32)
at Function.Module._load (internal/modules/cjs/loader.js:711:12)
at Module.require (internal/modules/cjs/loader.js:838:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (/Users/username/Desktop/nodeauthorization/bin/www:7:11)
at Module._compile (internal/modules/cjs/loader.js:945:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:962:10)
at Module.load (internal/modules/cjs/loader.js:798:32)
at Function.Module._load (internal/modules/cjs/loader.js:711:12)
at Function.Module.runMain (internal/modules/cjs/loader.js:1014:10)
at internal/main/run_main_module.js:17:11
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! nodeauthorization@0.0.0 start: `node ./bin/www`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the nodeauthorization@0.0.0 start script.
我该如何解决?