找不到模块 'js'

Cannot find module 'js'

添加请求后出现这样的错误。我尝试 npm install js 并在我的 app.js 文件中添加 var js = require("js") ,但它没有一点帮助都没有。我 运行 我的本地主机上有一个快速服务器。

Error: Cannot find module 'js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:611:15)
    at Function.Module._load (internal/modules/cjs/loader.js:537:25)
    at Module.require (internal/modules/cjs/loader.js:665:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at new View (E:\me\univercity\ais_node\cashdesk\node_modules\express\lib\view.js:81:14)
    at Function.render (E:\me\univercity\ais_node\cashdesk\node_modules\express\lib\application.js:570:12)
    at ServerResponse.render (E:\me\univercity\ais_node\cashdesk\node_modules\express\lib\response.js:1012:7)
    at E:\me\univercity\ais_node\cashdesk\app.js:201:9
    at Layer.handle [as handle_request] (E:\me\univercity\ais_node\cashdesk\node_modules\express\lib\router\layer.js:95:5)
    at next (E:\me\univercity\ais_node\cashdesk\node_modules\express\lib\router\route.js:137:13)

这是我添加的请求

app.get("/category/:id", function(req, res){
    var id = parseInt(req.params.id.charAt(1));
    itemsCopy = items.filter(function(el){
        console.log(el);
        return el.category.find(c => c == id);
    });

    console.log(itemsCopy);
    res.render("index.js", {items: itemsCopy});
});

npm install js 没有帮助。 这是我的 package.json

{
  "name": "blog",
  "version": "1.0.0",
  "description": "",
  "main": "app.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "body-parser": "^1.19.0",
    "ejs": "^3.1.3",
    "express": "^4.17.1",
    "js": "^0.1.0"
  }
}

问题似乎出在那些js函数filterfind,但我不知道如何让Node可以理解它们.

更新: 这就是物品的样子。我需要按类别过滤它们。我只想显示那些在字段 category.

中具有过滤值的那些
items = [
    {
        name: "Lorem",
        price: 16,
        descr: "This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.",
        warranity: true,
        warranity_length: 6,
        warranity_rules: "Do not put under water",
        category: [0]
    },
    {
        name: "ipsum",
        price: 67,
        descr: "This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.",
        warranity: true,
        warranity_length: 6,
        category: [0,1]

    }
] 

我这里有错字。 index.js 而不是 index.ejsres.render() .这个是正确的

app.get("/category/:id", function(req, res){
    var id = parseInt(req.params.id.charAt(1));
    itemsCopy = items.filter(function(el){
        console.log(el);
        return el.category.find(c => c == id);
    });

    console.log(itemsCopy);
    res.render("index.ejs", {items: itemsCopy});
});
``