简体   繁体   中英

module.js:491 throw err; Error: Cannot find module 'www/node-str/index.js'

I'm with this problem and i'm not able to solve, as far as irealized i did not find any errors, but i'm a beginner, so i do not know much, here is the code:

[nodemon] starting `node index.js`
module.js:491
throw err;
^

Error: Cannot find module '/www/node-str/index.js'
at Function.Module._resolveFilename (module.js:489:15) 
at Function.Module._load (module.js:439:25)
at Function.Module.runMain (module.js:609:10)
at startup (bootstrap_node.js:158:16)
at bootstrap_node.js:598:3
[nodemon] app crashed - waiting for file changes before starting...

app.js

 const express = require('express');
 const bodyParser = require('body-parser');

 const app = express();
 const router = express.Router();


 const index = require('./routes/index');
 const products = require('./routes/products')

 app.use(bodyParser.json());
 app.use(bodyParser.urlencoded({ extended: false}));

 app.use('/', index);
 app.use('/products', products);

 module.exports = app;

index.js

 'use strict';

 const express = require('express');
 const router = express.Router();

 router.get('/', (req, res, next) => {
 res.status(200).send({ title: "Node Store API", version: "0.0.1" });
 });

 module.exports = router;

Directory

你的 package.json 是:

"main": "src/app.js"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM