I have a script that runs some
npm commands based on a user like
#!/bin/sh /bin/su someuser -c " cd /opt/app1/; env -i git remote update; env -i git pull origin dev; cd /opt/app1/client/; npm run build; "
git commands run correctly. The
npm command runs and builds the files but throws lots of errors about
Node Sass could not find a binding for your current environment: Linux 64-bit with Node.js 8.x Found bindings for the following environments: - Linux 64-bit with Node.js 9.x This usually happens because your environment has changed since running `npm install`. Run `npm rebuild node-sass --force` to build the binding for your current environment.
If I run
npm run build as the user from terminal, everything builds fine. I even tried
env -i npm run build in the script and that just says
env: ‘npm’: No such file or directory. So i then tried
env -i /usr/local/bin/npm run build and oddly that returned
/usr/bin/env: 'node': No such file or directory.
I though that the
user -c would set me up with all env like the user was logged in and that
env -i would give me clean
env without the parent.
#!/bin/sh /bin/su someuser - -c " cd /opt/app1/; git remote update; git pull origin dev; cd /opt/app1/client/; npm run build; "
That last attempt returns same as first: git commands work, build throws errors about sass and environment as if something is different than when i run the command as the user from the terminal.
Any idea why this command is not working correctly?