hosseinkhalili
hosseinkhalili
WWasp-lang
Created by hosseinkhalili on 5/22/2024 in #đŸ™‹questions
wasp start in custom port that added in .env
i have to start wasp app in dynamic port every time like this, but how i can use .env variable in vite.config.ts
import { defineConfig } from 'vite'

export default defineConfig({
server: {
open: true,
port: process.env.WASP_WEB_CLIENT_URL_PORT,
},
})
import { defineConfig } from 'vite'

export default defineConfig({
server: {
open: true,
port: process.env.WASP_WEB_CLIENT_URL_PORT,
},
})
when i run wasp start , the console returns error
[Client!] failed to load config from /mnt/directory-address/.wasp/out/web-app/vite.config.ts
[Client!] error when starting dev server:
[Client!] TypeError: Cannot read properties of undefined (reading 'VITE_REACT_APP_WASP_WEB_CLIENT_PORT')
[Client!] at file:////mnt/directory-address/.wasp/out/web-app/vite.config.ts.timestamp-1716384226844-ee0a203ae7d89.mjs:10:27
[Client!] at ModuleJob.run (node:internal/modules/esm/module_job:193:25)
[Client!] at async Promise.all (index 0)
[Client!] at async ESMLoader.import (node:internal/modules/esm/loader:530:24)
[Client!] at async loadConfigFromBundledFile (file:///mnt/directory-address/.wasp/out/web-app/node_modules/vite/dist/node/chunks/dep-41cf5ffd.js:66337:21)
[Client!] at async loadConfigFromFile (file:///mnt/directory-address/.wasp/out/web-app/node_modules/vite/dist/node/chunks/dep-41cf5ffd.js:66186:28)
[Client!] at async resolveConfig (file:///mnt/directory-address/.wasp/out/web-app/node_modules/vite/dist/node/chunks/dep-41cf5ffd.js:65782:28)
[Client!] at async _createServer (file:///mnt/directory-address/.wasp/out/web-app/node_modules/vite/dist/node/chunks/dep-41cf5ffd.js:65051:20)
[Client!] at async CAC.<anonymous> (file:///mnt/directory-address/.wasp/out/web-app/node_modules/vite/dist/node/cli.js:763:24)
[Client!] failed to load config from /mnt/directory-address/.wasp/out/web-app/vite.config.ts
[Client!] error when starting dev server:
[Client!] TypeError: Cannot read properties of undefined (reading 'VITE_REACT_APP_WASP_WEB_CLIENT_PORT')
[Client!] at file:////mnt/directory-address/.wasp/out/web-app/vite.config.ts.timestamp-1716384226844-ee0a203ae7d89.mjs:10:27
[Client!] at ModuleJob.run (node:internal/modules/esm/module_job:193:25)
[Client!] at async Promise.all (index 0)
[Client!] at async ESMLoader.import (node:internal/modules/esm/loader:530:24)
[Client!] at async loadConfigFromBundledFile (file:///mnt/directory-address/.wasp/out/web-app/node_modules/vite/dist/node/chunks/dep-41cf5ffd.js:66337:21)
[Client!] at async loadConfigFromFile (file:///mnt/directory-address/.wasp/out/web-app/node_modules/vite/dist/node/chunks/dep-41cf5ffd.js:66186:28)
[Client!] at async resolveConfig (file:///mnt/directory-address/.wasp/out/web-app/node_modules/vite/dist/node/chunks/dep-41cf5ffd.js:65782:28)
[Client!] at async _createServer (file:///mnt/directory-address/.wasp/out/web-app/node_modules/vite/dist/node/chunks/dep-41cf5ffd.js:65051:20)
[Client!] at async CAC.<anonymous> (file:///mnt/directory-address/.wasp/out/web-app/node_modules/vite/dist/node/cli.js:763:24)
16 replies