在 运行 nodemon 时找不到模块 'express'。抛出错误,应用程序崩溃

Cannot find module 'express' while running nodemon. Throw error, app crashed

我刚刚在之前安装 nodemon 的目录中使用 "create new project : express --view=ejs project2" 创建了一个项目 "project2"。

但是当我在终端上输入 "nodemon" 时,错误显示:

我也安装了 http-errors,但错误消息仍然存在。 我应该怎么做才能解决这个问题?

在项目中尝试 运行 npm install

在我使用以下方法在 project2 中安装 express 后它起作用了:

npm install express --save

但是,仍然有更多的错误消息,例如: "Could not find module 'cookie-parser'," 通过安装所有相应的模块全部解决。