Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cant use node environment variables #148

Closed
Phara0h opened this issue Mar 28, 2019 · 4 comments
Closed

Cant use node environment variables #148

Phara0h opened this issue Mar 28, 2019 · 4 comments

Comments

@Phara0h
Copy link

Phara0h commented Mar 28, 2019

Expected Behavior

Should allow env to be set like it says you can in the documentation
https://clinicjs.org/documentation/cli

Current Behavior

clinic doctor -- NODE_PATH="." node index.js 
To generate the report press: Ctrl + C
events.js:167
      throw er; // Unhandled 'error' event
      ^

Error: spawn NODE_PATH=. ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:232:19)
    at onErrorNT (internal/child_process.js:407:16)
    at process._tickCallback (internal/process/next_tick.js:63:19)
    at Function.Module.runMain (internal/modules/cjs/loader.js:745:11)
    at startup (internal/bootstrap/node.js:282:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)
Emitted 'error' event at:
    at Process.ChildProcess._handle.onexit (internal/child_process.js:238:12)
    at onErrorNT (internal/child_process.js:407:16)
    [... lines matching original stack trace ...]
    at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)

Steps to Reproduce (for bugs)

  1. try to run clinic doctor -- NODE_PATH="." node index.js

Sample upload

Environment

  • Clinic.js version: Clinic.js v4.0.2 Doctor v4.0.2
  • Node.js version: v10.14.2
  • Operating system and version: OSX 10.14.3
@goto-bus-stop
Copy link
Contributor

hmm, i don't think this was ever actually supported!

you can do NODE_ENV=production clinic doctor -- node server.js in most (all?) cases, instead, since server.js will just inherit the env from clinic.

if there is a case where the ENV=val clinic doctor -- node server.js form doesn't work as intended, but clinic doctor -- ENV=val node server.js would, we could support that too.

thanks for opening an issue, i'll look into fixing the docs.

@Phara0h
Copy link
Author

Phara0h commented Mar 28, 2019

hmm, i don't think this was ever actually supported!

you can do NODE_ENV=production clinic doctor -- node server.js in most (all?) cases, instead, since server.js will just inherit the env from clinic.

if there is a case where the ENV=val clinic doctor -- node server.js form doesn't work as intended, but clinic doctor -- ENV=val node server.js would, we could support that too.

thanks for opening an issue, i'll look into fixing the docs.

Thanks for the reply so this is our "npm start" script that gets ran.

export NODE_PATH="$(pwd)/src/lib"
export $(sed -e '/^#/d' .env | xargs)

node src/index.js

That second export is setting a bunch of environment variables in a text file and for some reason clinic wont work with it.

@samartioli
Copy link

Can work around by using a pre-launch script and including the .env implicitly with the dotenv npm module

'use strict';
var path = require('path');

require('dotenv').config({path: path.join(__dirname, '.env')});

process.env.NODE_PATH = path.join(__dirname, 'src/lib');

require('src/index.js');

wentout added a commit to wentout/node-clinic-doctor that referenced this issue Apr 11, 2019
clinicjs#132

But ths still relates to current state
clinicjs/node-clinic#148

So there might be changes done to fix NODE_PATH back, for legacy projects.
wentout added a commit to wentout/node-clinic-bubbleprof that referenced this issue Apr 11, 2019
clinicjs/node-clinic-doctor#132

But ths still relates to current state
clinicjs/node-clinic#148

So there might be changes done to fix NODE_PATH back, for legacy projects.
goto-bus-stop pushed a commit to clinicjs/node-clinic-bubbleprof that referenced this issue Apr 25, 2019
* Seems this doesn't matter anymore
clinicjs/node-clinic-doctor#132

But ths still relates to current state
clinicjs/node-clinic#148

So there might be changes done to fix NODE_PATH back, for legacy projects.

* fix CI comma

* oneliner for makeInjectPath

* Additional Fix after code-review.
Thanks to @goto-bus-stop !
NODE_PATH works from both prospects.

* Finally got rid of broken parts.
goto-bus-stop pushed a commit to clinicjs/node-clinic-doctor that referenced this issue Apr 25, 2019
* Seems this doesn't matter anymore
#132

But ths still relates to current state
clinicjs/node-clinic#148

So there might be changes done to fix NODE_PATH back, for legacy projects.

* fix CI comma & occasionally replaced logger path

* onliner for makeInjectPath

* Additional Fix after code-review.
Thanks to @goto-bus-stop !
NODE_PATH works from both prospects.

* Finally got rid of broken parts.

* investigation checks issues

* investigation checks issues 2

* reverting changes for the test
@DylanC
Copy link
Contributor

DylanC commented Feb 5, 2020

@goto-bus-stop - Seems a fix was pushed for this already?

@DylanC DylanC closed this as completed Feb 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants