Closed dkleber89 closed 2 years ago
When i use the same in Alpine Linux Container it works like expected
Thanks for raising this - I don't develop natively on Windows (always through WSL or macOS), so I hadn't run into it before.
To rule out interference from cross-env
or cross-spawn
, please can you see if the following works for you as a test?
set NODE_OPTIONS="-r next-logger"
npx next start
# ...or whichever script you have aliases to "next start"
# e.g. npm run start
When i set NODE_OPTIONS directly then it works as expected.
Maybe there is a Problem with cross-env ... but can´t find out what it is ... the other env variables working fine with the cross-env
I'm also interested in using this to develop on Windows without having to ask my team to manually set config vars. Happy to help test if you have ideas.
@cahaseler - the library needs to be loaded into the Node environment before any other code, including Next.js. The fastest way is to use NODE_OPTIONS
to require a module into the environment before starting Next.js' CLI - and environment variables are needed for this.
Alternatively, you could write a tiny script that requires next-logger
and then the Next.js' CLI - and then run this, instead of the Next.js CLI. For example:
require('next-logger')
require('next/dist/bin/next')
node next.js
This seems to be an issue with cross-env: #143, #248.
PS: I've just fixed this in my library https://github.com/laggingreflex/win-node-env/issues/8 which is an alternative to cross-env.
I'm going to close this, as an issue with cross-env
. If it turns out to be this library, please re-open this.
When i add next-logger to my Project im not able to start nextjs anymore:
Used Versions: "next": "^11.1.2", "next-logger": "^2.1.1",
OS: Windows for dev and later Alpine Linux Kubernetes Container
What do im wrong?