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

use dotenv with vinxi start #277

Open
birkskyum opened this issue Apr 9, 2024 · 5 comments
Open

use dotenv with vinxi start #277

birkskyum opened this issue Apr 9, 2024 · 5 comments

Comments

@birkskyum
Copy link
Contributor

birkskyum commented Apr 9, 2024

When developing with vinxi dev the .env file will be loaded correctly with vite.

After building and starting, none of the import.meta.env are found.

My current alternative to vinxi start is pnpx node-env-run .output/server/index.mjs

related:

@birkskyum
Copy link
Contributor Author

and ofc node --env-file

@vincehi
Copy link

vincehi commented Sep 27, 2024

You can use node --env-file=.env ./node_modules/.bin/vinxi dev and process.env.YOUPI

@birkskyum
Copy link
Contributor Author

@vincehi , this ticket is specifically for vinxi start, because if the .env files can't be loaded with start there's imo limited utility of the start cli entry.

@vincehi
Copy link

vincehi commented Oct 30, 2024

@birkskyum I have no problem loading the env var with this command for the start node --env-file=.env ./node_modules/.bin/vinxi start

@Ximaz
Copy link

Ximaz commented Nov 1, 2024

@birkskyum I have no problem loading the env var with this command for the start node --env-file=.env ./node_modules/.bin/vinxi start

Should you work around work when using pnpm package manager (I actually am trying for dev, not start, but I don't think it matters tbh...) ? Because node_modules/.bin/vinxi doesn't seem to work as expected :

app % pnpm dev                                  

> <project>@ dev <project>/app
> node --env-file=../.env ./node_modules/.bin/vinxi dev --port 8081

<project>/app/node_modules/.bin/vinxi:2
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
          ^^^^^^^

SyntaxError: missing ) after argument list
    at wrapSafe (node:internal/modules/cjs/loader:1378:20)
    at Module._compile (node:internal/modules/cjs/loader:1428:41)
    at Module._extensions..js (node:internal/modules/cjs/loader:1548:10)
    at Module.load (node:internal/modules/cjs/loader:1288:32)
    at Module._load (node:internal/modules/cjs/loader:1104:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)
    at node:internal/main/run_main_module:28:49

Node.js v20.18.0
 ELIFECYCLE  Command failed with exit code 1.

It seems that node_modules/.bin/vinxi is a shell script that node is trying to run, which obviously can't work. Any idea ? Here is my package.json file :

{
  "name": "<project>",
  "type": "module",
  "scripts": {
    "dev": "node --env-file=../.env ./node_modules/.bin/vinxi dev --port 8081",
    "build": "vinxi build",
    "start": "vinxi start --port 8081",
    "version": "vinxi version",
    "vinxi": "vinxi"
  },
  "dependencies": {
    "@kobalte/core": "^0.13.7",
    "@solidjs/meta": "^0.29.4",
    "@solidjs/router": "^0.14.10",
    "@solidjs/start": "^1.0.9",
    "archiver": "^7.0.1",
    "class-variance-authority": "^0.7.0",
    "clsx": "^2.1.1",
    "fluent-ffmpeg": "^2.1.3",
    "light-audio-converter": "^1.0.6",
    "solid-js": "^1.9.2",
    "tailwind-merge": "^2.5.4",
    "tailwindcss-animate": "^1.0.7",
    "vinxi": "^0.4.3"
  },
  "engines": {
    "node": ">=18"
  },
  "devDependencies": {
    "@types/archiver": "^6.0.3",
    "@types/fluent-ffmpeg": "^2.1.27",
    "autoprefixer": "^10.4.20",
    "postcss": "^8.4.47",
    "tailwindcss": "^3.4.14"
  }
}

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

3 participants