Hi there! :slightly_smiling_face: I’m trying to us...
# sst
j
Hi there! 🙂 I’m trying to use the
version
value of the
package.json
file in my lambda script. Therefore, as described in the documentation, I edited the
index.js
file in the
stacks
directory, to contain this bit of code:
Copy code
export default function main(app) {
  // Set default runtime for all functions
  app.setDefaultFunctionProps((stack) => ({
    runtime: "nodejs12.x",
    environment: {
      SCRIPT_VERSION: process.env.npm_package_version,
      CALENDAR_ID: ssm.StringParameter.valueForStringParameter(stack, "/CALENDAR_ID"),
....
SCRIPT_VERSION
should now contain the value of
version
. This works fine while developping locally, but once deployed, the value is always
undefined
. Is the
package.json
file ignored maybe? 🙏
f
Hey @Jakob Fix, where does the
npm_package_version
environment variable come from?
j
f
Got it! Is the project deployed via SEED?
On SEED, It’s deployed using
npx sst deploy
instead of
npm run deploy
. And I just tried running
npx
and
npm_package_
environment variable is not set.
j
Hi Frank, sorry for the delay! I’m using
npx sst deploy --stage prod
.
f
Are you running that locally? Can you try running
npm run deploy -- --stage prod
The
npm_package_
environment variable only applies to
npm run
j
I’ll give that a try, thanks!
👍