首页 > 解决方案 > 找不到模块 nodemon

问题描述

我的 config.js 文件:

const config = {
    development: {
        PORT: 5000
    },

    production: {
        PORT: 80
    }
};

module.exports = config[process.env.NODE_ENV.trim()];

这是我的 package.json:

"scripts": {
    "start": "SET NODE_ENV=development && nodemon ./server.js",
    "prod": "SET NODE_ENV=production && node ./server.js"
  },

"dependencies": {
    "express": "^4.17.1"
  },
  "devDependencies": {
    "nodemon": "^2.0.12"
  }

server.js 文件:

const config = require('./config/config');

app.listen(config.PORT, () => console.log(`Server is running on port ${config.PORT}...`));

问题:

> cubicle@1.0.0 start C:\Users\stani\Documents\GitHub\Intro-to-JavaScript\Softuni\5. Back-end\3. ExpressJS & Templating\cubicle
> SET NODE_ENV=development && nodemon ./server.js

'Templating\cubicle\node_modules\.bin\' is not recognized as an internal or external command,
operable program or batch file.
internal/modules/cjs/loader.js:888
  throw err;
  ^

Error: Cannot find module 'C:\Users\stani\Documents\GitHub\Intro-to-JavaScript\Softuni\5. Back-end\nodemon\bin\nodemon.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:885:15)
    at Function.Module._load (internal/modules/cjs/loader.js:730:27)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
    at internal/main/run_main_module.js:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! cubicle@1.0.0 start: `SET NODE_ENV=development && nodemon ./server.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the cubicle@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\stani\AppData\Roaming\npm-cache\_logs\2021-08-10T16_07_01_722Z-debug.log

我尝试在全球范围内安装它以及我在互联网上阅读的其他内容,但它归结为这个错误,我不明白似乎是什么问题。

标签: javascriptnode.jsexpressnodemon

解决方案


推荐阅读