javascript - 找不到模块 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
我尝试在全球范围内安装它以及我在互联网上阅读的其他内容,但它归结为这个错误,我不明白似乎是什么问题。
解决方案
推荐阅读
- spring - 在`RestTemplate`抛出`RestClientException`后如何从响应中获取数据,因为它无法解析它
- c# - 如何在大字符串的每一行添加后缀
- c# - DataGrid Column Width 字符串到宽度转换器 MVVM
- mapbox - 添加 url 重定向到 mapbox 图标
- lte - NextEPC + OpemIMS = 具有 VoLTE 功能的 LTE 节点内核?
- node.js - Puppeteer 关闭 javascript 警报框
- airflow - 通过 Cloud Composer 运行气流时的授权错误
- arrays - 将数组与 PDL 中的一个元素相乘时如何避免错误?
- asp.net - 如何在 ASP.NET Framework 4.x Web API 中实现 OpenID OAuth2 Server?
- excel - Excel中的时间格式