Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

source. env command does not work when called from package.json scripts in Ubuntu

Tags:

ubuntu

yarnpkg

I have the following entry for the scripts key/property in my package.json

"stop": "source .env && yarn doc:stop && lsof -t -i tcp:$EXPRESS_PORT | xargs kill 2> /dev/null && pgrep -f $(pwd) | xargs kill 2> /dev/null",

It does not work when I execute

yarn stop

It throws the following error

/bin/sh: 1: source: not found

But I can call execute directly from the Ubuntu command terminal with no error

source .env

I get the same error when using . (dot) instead of source.

/bin/sh: 1: .: .env: not found

How can I fix?

Thanks

like image 829
Juan Pablo Fernandez Avatar asked Feb 05 '26 19:02

Juan Pablo Fernandez


1 Answers

Seems like using . .env would work See: https://stackoverflow.com/a/45089609/5155484 and https://wiki.ubuntu.com/DashAsBinSh#source

like image 59
William Desportes Avatar answered Feb 07 '26 22:02

William Desportes