现在错误是更改cookie解析器安装,但是当我命令节点应用程序时,它会给出错误" cookie-parser not found"

时间:2017-08-17 05:49:51

标签: node.js express total.js

我的节点版本8.3.0,npm -v 5.3.0,Express。

错误

module.js:491
    throw err;
    ^

    Error: Cannot find module 'cookie-Parser'
        at Function.Module._resolveFilename (module.js:489:15)
        at Function.Module._load (module.js:439:25)
        at Module.require (module.js:517:17)
        at require (internal/module.js:11:18)
        at Object.<anonymous> (/var/www/html/Ideabazar/app.js:3:20)
        at Module._compile (module.js:573:30)
        at Object.Module._extensions..js (module.js:584:10)
        at Module.load (module.js:507:32)
        at tryModuleLoad (module.js:470:12)
        at Function.Module._load (module.js:462:3)

2 个答案:

答案 0 :(得分:0)

模块名称错误。尝试require cookie-parser而非cookie-Parser

var cookieParser = require('cookie-parser')

答案 1 :(得分:0)

首先,您需要在控制台中安装cookie-parser:

$i = 14;

然后在npm install cookie-parser 文件中添加var cookieParser = require('cookie-parser')

for ref server.js doc:https://www.npmjs.com/package/cookie-parser