Below is a strange error when I try to use expressValidator module in nodejs.
Error: Cannot find module 'expressValidator'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (C:\wamp\www\learning\nodejs_udemy\node_auth\app.js:5:
24)
Any mistake I made in my app.js?
var expressValidator = require('expressValidator');
// 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
};
}
}));
I follow the github usage guide but I still got an error.
Below is a strange error when I try to use expressValidator module in nodejs.
Error: Cannot find module 'expressValidator'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (C:\wamp\www\learning\nodejs_udemy\node_auth\app.js:5:
24)
Any mistake I made in my app.js?
var expressValidator = require('expressValidator');
// 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
};
}
}));
I follow the github usage guide but I still got an error.
Share Improve this question asked Oct 4, 2015 at 12:54 Alice XuAlice Xu 5431 gold badge6 silver badges20 bronze badges 1- And you have actually installed that? – Roope Commented Oct 4, 2015 at 12:56
2 Answers
Reset to default 2npm modules can't have uppercase letters, the module is called express-validator
, not expressValidator
. As stated in express-validator's documentation, do:
var expressValidator = require('express-validator');
make sure to
npm i --save express-validator
before you try to use it.
I have similar issue. On my case I did a pull request from git and didn't install all latest packages.
yarn install
OR
npm install
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745627991a4636926.html
评论列表(0条)