在node.js webscrapper中找不到app.js.

时间:2017-07-18 13:27:47

标签: node.js

我刚开始学习node.js并遵循this中的webscrapper示例。输入" npm start"在终端和访问localhost:8081 / scrape。我收到此错误消息。我确定这个文件目录是正确的。

  

错误:未找到       在C:\ Users \ user \ Desktop \ Node.JS \ webscrapper \ app.js:35:13

文件树: here

的package.json

{
  "name": "webscrapper",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node ./bin/www"
  },
  "dependencies": {
    "body-parser": "~1.17.1",
    "cookie-parser": "~1.4.3",
    "debug": "~2.6.3",
    "express": "~4.15.2",
    "jade": "~1.11.0",
    "morgan": "~1.8.1",
    "serve-favicon": "~2.4.2",
    "request": "latest",
    "cheerio": "latest"
  }
}

删除app.js中express生成的以下代码后,就可以了!我可以问为什么?

// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');

// uncomment after placing your favicon in /public
//app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));

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

// catch 404 and forward to error handler
app.use(function(req, res, next) {
  var err = new Error('Not Found');
  err.status = 404;
  next(err);
});

// error handler
app.use(function(err, req, res, next) {
  // set locals, only providing error in development
  res.locals.message = err.message;
  res.locals.error = req.app.get('env') === 'development' ? err : {};

  // render the error page
  res.status(err.status || 500);
  res.render('error');
});

0 个答案:

没有答案