I have installed chromatic to my project and I wanted to add a command to npm scripts for it with following setting in package.json
.
"scripts": {
...
"chromatic": "chromatic --project-token=$CHROMATIC_PROJECT_TOKEN",
},
Since the CHROMATIC_PROJECT_TOKEN
is secret token, I decided to define an environment variable in .env.local
along the rule of Next.js.
Note: similar to Default Environment Variables, .env.test file should be included in your repository, but .env.test.local shouldn't, as .env*.local are intended to be ignored through .gitignore.
# chromatic token
CHROMATIC_PROJECT_TOKEN=1234567890
And I run a following command after executing $ next dev
,
$ yarn chromatic
and this error occured.
I reseached in github seeing other's code using chromatic and they seemed ended up hardcoding the token to the npm scripts.
Does anyone can tell me how to let npm scripts read the environment variables defined in .env.local
?