Hello,
When running sam build npm config optional=false seems to be just ignored whether it is passed through env variables, .npmrc or whatever way to do it. npm config ls -l shows that optional=false is set correctly.
aws --version : aws-cli/1.16.260 Python/3.7.5 Darwin/17.7.0 botocore/1.12.250
node -v : v10.17.0
npm -v : 6.11.3