执行DEBUG=knex* nodemon server.js报错:‘DEBUG’未被识别
Hey there! That error you're hitting is super common when trying to run Unix-style environment variable commands on Windows—let's get it sorted out quickly.
The root issue is that Windows Command Prompt and PowerShell don't understand the DEBUG=knex* syntax used in Linux/macOS shells. Here are the two best ways to fix this:
1. Use cross-env (Recommended, Cross-Platform)
This package handles environment variable setup across all operating systems, so you won't have to worry about platform differences again:
- First, install it as a dev dependency:
npm install cross-env --save-dev - Open your
package.jsonfile and update thestartscript to usecross-env:"scripts": { "start": "cross-env DEBUG=knex* nodemon server.js" } - Now run
npm startlike you normally would—this should work without any errors!
2. Manual Environment Variable Setup (For Quick Testing)
If you don't want to install an extra package, you can set the variable directly in your Windows shell:
- Command Prompt (CMD):
set DEBUG=knex* && nodemon server.js - PowerShell:
$env:DEBUG="knex*"; nodemon server.js
Note that this method only works for the current shell session—you'll have to re-run the command if you open a new window.
That should resolve the ELIFECYCLE error too, since the original failure was just from the unrecognized DEBUG command.
内容的提问来源于stack exchange,提问作者Raddy T

