I'm trying to start my server with nodemon
, but it crashes with the following output.
The error ERROR: Unrecognized environment. Aborting.
seems quite rare, from a Google search.
Ran the same code in Windows 10 and a WSL2 Ubuntu set up. Both had the same results. The server does start for my coworker for some reason, though.
user@LAPTOP:~/myproject$ npm run start:dev > myproject@0.0.0 start:dev /home/user/myproject > nodemon [nodemon] 2.0.7 [nodemon] to restart at any time, enter `rs` [nodemon] watching path(s): src/**/* [nodemon] watching extensions: ts,html [nodemon] starting `./node_modules/.bin/ts-node -r tsconfig-paths/register ./src` [2021-03-23T04:11:42.704Z] ERROR: Unrecognized environment. Aborting. [nodemon] app crashed - waiting for file changes before starting... ^C user@LAPTOP:~/myproject$ npm -v 6.14.11 user@LAPTOP:~/myproject$ node -v v15.12.0
development.env
:
## Environment ## NODE_ENV=development ## Server ## PORT=3000 HOST=localhost # ...
config/config.js
// Configure environment sequelize to use environment variables provided in src/pre-start/env const node_env = process.env.NODE_ENV || 'development'; //const { resourceLimits } = require('node:worker_threads'); const { resourceLimits } = require('worker_threads'); // Source the correct environment const path = require('path'); const result = require('dotenv').config({ path: path.resolve(process.cwd(), 'src', 'pre-start', 'env', `${node_env}.env`) }); if (result.error) { throw result.error; } module.exports = { development: { username: process.env.DEV_DB_USERNAME, password: process.env.DEV_DB_PASSWORD, database: process.env.DEV_DB_NAME, host: process.env.DEV_DB_HOSTNAME || 'localhost', dialect: 'postgres' }, // ... };
package.json
{ "name": "myproject", "version": "0.0.0", "scripts": { "build": "./node_modules/.bin/ts-node build.ts", "lint": "eslint . --ext .ts", "start": "node -r module-alias/register ./dist --env=production", "start:dev": "nodemon", "test": "nodemon --config ./spec/nodemon.json" }, "nodemonConfig": { "watch": [ "src" ], "ext": "ts, html", "ignore": [ "src/public" ], "exec": "./node_modules/.bin/ts-node -r tsconfig-paths/register ./src" }, "_moduleAliases": { "@models": "dist/models", "@shared": "dist/shared", "@server": "dist/Server" }, "eslintConfig": { "parser": "@typescript-eslint/parser", "plugins": [ "@typescript-eslint" ], "extends": [ "eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:@typescript-eslint/recommended-requiring-type-checking" ], "parserOptions": { "project": "./tsconfig.json" }, "rules": { "max-len": [ "error", { "code": 100 } ], "no-console": 1, "no-extra-boolean-cast": 0, "@typescript-eslint/restrict-plus-operands": 0, "@typescript-eslint/explicit-module-boundary-types": 0, "@typescript-eslint/no-explicit-any": 0, "@typescript-eslint/no-floating-promises": 0, "@typescript-eslint/no-unsafe-member-access": 0, "@typescript-eslint/no-unsafe-assignment": 0 } }, "eslintIgnore": [ "src/public/", "build.ts" ], "dependencies": { "command-line-args": "^5.1.1", "cookie-parser": "^1.4.5", "cron": "^1.8.2", "dotenv": "^8.2.0", "express": "^4.17.1", "express-async-errors": "^3.1.1", "helmet": "^4.4.1", "http-status-codes": "^2.1.4", "jet-logger": "^1.0.4", "jsonfile": "^6.1.0", "module-alias": "^2.2.2", "morgan": "^1.10.0", "pg": "^8.5.1", "pg-hstore": "^2.3.3", "sequelize": "^6.5.0", "sequelize-cli": "^6.2.0", "twilio": "^3.57.0" }, "devDependencies": { "@types/command-line-args": "^5.0.0", "@types/cookie-parser": "^1.4.2", "@types/cron": "^1.7.2", "@types/find": "^0.2.1", "@types/fs-extra": "^9.0.8", "@types/jasmine": "^3.6.6", "@types/jsonfile": "^6.0.0", "@types/morgan": "^1.9.2", "@types/node": "^14.14.32", "@types/pg": "^7.14.11", "@types/qs": "^6.9.6", "@types/supertest": "^2.0.10", "@types/validator": "^13.1.3", "@typescript-eslint/eslint-plugin": "^4.17.0", "@typescript-eslint/parser": "^4.17.0", "eslint": "^7.21.0", "find": "^0.3.0", "fs-extra": "^9.1.0", "jasmine": "^3.6.4", "nodemon": "^2.0.7", "supertest": "^6.1.3", "ts-node": "^9.1.1", "tsconfig-paths": "^3.9.0", "typescript": "^4.2.3" } }
https://stackoverflow.com/questions/66757548/unable-to-launch-nodemon-environment March 23, 2021 at 01:05PM
没有评论:
发表评论