Closed leads closed 4 years ago
Deleted node_modules
Ran npm install
Ran npm rebuild node-sass
No change but this is the output if it's useful:
Toms-MacBook-Pro:supersecretproject tom$ npm rebuild node-sass
node-sass@4.12.0 install /Users/tom/Code/supersecretproject/node_modules/node-sass node scripts/install.js
node-sass build Binary found at /Users/tom/Code/supersecretproject/node_modules/node-sass/vendor/darwin-x64-64/binding.node
node-sass@4.12.0 postinstall /Users/tom/Code/supersecretproject/node_modules/node-sass node scripts/build.js
Binary found at /Users/tom/Code/supersecretproject/node_modules/node-sass/vendor/darwin-x64-64/binding.node Testing binary Binary is fine node-sass@4.12.0 /Users/tom/Code/supersecretproject/node_modules/node-sass
Solved it!
In node_modules/node-sass/vendor/
there was only a darwin-x64-64/binding.node
folder/file.
From this github page I downloaded linux-x64-64__binding.node
renamed it to binding.node
and created a linux-x64-64
folder and put it in there: node_modules/node-sass/vendor/linux-x64-64/binding.node
Then redeployed the lambda and all is well. I just need to remember to do that if/when I do a yarn update or similar.
Yes, that is a proper fix - include all binaries for all node or platform versions you need in the deployment package
Is there no proper fix for this? Manually changing this file seems silly as all my developers need to now do this?
What is the use case for deploying node-sass to lambda? It's intended to be a development tool.
On Thu, 21 Nov 2019, 6:56 pm Ashok Raju, notifications@github.com wrote:
Is there no proper fix for this? Manually changing this file seems silly as all my developers need to now do this?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/sass/node-sass/issues/2724?email_source=notifications&email_token=AAENSWH5IRGMXQW5XONLF2DQUY5MXA5CNFSM4ISF5UM2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEZJY2Y#issuecomment-556964971, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAENSWAIICCOWMEUFXZOLOLQUY5MXANCNFSM4ISF5UMQ .
@rajuashok This is always the case when the dev environment is different from the deployment platform.
What is the use case for deploying node-sass to lambda? It's intended to be a development tool. … On Thu, 21 Nov 2019, 6:56 pm Ashok Raju, @.***> wrote: Is there no proper fix for this? Manually changing this file seems silly as all my developers need to now do this? — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#2724?email_source=notifications&email_token=AAENSWH5IRGMXQW5XONLF2DQUY5MXA5CNFSM4ISF5UM2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEZJY2Y#issuecomment-556964971>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAENSWAIICCOWMEUFXZOLOLQUY5MXANCNFSM4ISF5UMQ .
Hmm good question. So I'm using email-templates (https://www.npmjs.com/package/email-templates), which, when I deploy is giving me this error:
Failed to render email { Error: Cannot find module 'node-sass' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15) at Module._require.o.require (/var/task/serverless_sdk/index.js:9:90239) at require (internal/modules/cjs/helpers.js:25:18) at renderSass (/var/task/node_modules/email-templates/lib/template-manager.js:119:14) at /var/task/node_modules/email-templates/lib/template-manager.js:69:22 at Promise._execute (/var/task/node_modules/bluebird/js/release/debuggability.js:411:9) at Promise._resolveFromExecutor (/var/task/node_modules/bluebird/js/release/promise.js:518:18) at new Promise (/var/task/node_modules/bluebird/js/release/promise.js:103:10) at render (/var/task/node_modules/email-templates/lib/template-manager.js:51:10) at renderFile (/var/task/node_modules/email-templates/lib/util.js:110:38) at /var/task/node_modules/email-templates/lib/email-template.js:273:32 at tryCatcher (/var/task/node_modules/bluebird/js/release/util.js:16:23) at Promise._settlePromiseFromHandler (/var/task/node_modules/bluebird/js/release/promise.js:547:31) at Promise._settlePromise (/var/task/node_modules/bluebird/js/release/promise.js:604:18) at Promise._settlePromiseCtx (/var/task/node_modules/bluebird/js/release/promise.js:641:10) at _drainQueueStep (/var/task/node_modules/bluebird/js/release/async.js:97:12) code: 'MODULE_NOT_FOUND' }
So I tried installing node-sass, but now I'm getting the wrong env error.
What is the use case for deploying node-sass to lambda? It's intended to be a development tool. … On Thu, 21 Nov 2019, 6:56 pm Ashok Raju, @.***> wrote: Is there no proper fix for this? Manually changing this file seems silly as all my developers need to now do this? — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#2724?email_source=notifications&email_token=AAENSWH5IRGMXQW5XONLF2DQUY5MXA5CNFSM4ISF5UM2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEZJY2Y#issuecomment-556964971>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAENSWAIICCOWMEUFXZOLOLQUY5MXANCNFSM4ISF5UMQ .
I am running a rollup.js job with a lambda to generate HTML, CSS and JS which I then put in an S3 bucket.
Solved it!
In
node_modules/node-sass/vendor/
there was only adarwin-x64-64/binding.node
folder/file.From this github page I downloaded linux-x64-64__binding.node
renamed it to
binding.node
and created alinux-x64-64
folder and put it in there:node_modules/node-sass/vendor/linux-x64-64/binding.node
Then redeployed the lambda and all is well. I just need to remember to do that if/when I do a yarn update or similar.
So I tried doing this exact thing but my deployer is not finding the linux version of binding.node at all. Just curious how you got yours to include the file. I'm guessing my serverless deploy function is rebuilding npm and only packaging my environments binding.node.
If you are unable to upload arbitrary file with your deployment package I am afraid lambda environment might not be the best for you.
Solved it! In
node_modules/node-sass/vendor/
there was only adarwin-x64-64/binding.node
folder/file. From this github page I downloaded linux-x64-64__binding.node renamed it tobinding.node
and created alinux-x64-64
folder and put it in there:node_modules/node-sass/vendor/linux-x64-64/binding.node
Then redeployed the lambda and all is well. I just need to remember to do that if/when I do a yarn update or similar.So I tried doing this exact thing but my deployer is not finding the linux version of binding.node at all. Just curious how you got yours to include the file. I'm guessing my serverless deploy function is rebuilding npm and only packaging my environments binding.node.
this is my deploy Lambda command
"deploy": "babel-node scripts/copy-node-sass-vendor.js && sls deploy --stage prod"
which copies the file from my local files, to the node_modules file, which is all then bundled up and used by the Lambda.
I've attached the copy-node-sass-vendor.js file (renamed to .txt here so it can attached)
Hope it helps!
@xzyfer my specific use case for using node in lambda is to write out end user-generated scss that gets dynamically out and included in web authored scorm courses. Works great.
I am running (well, trying to!) a AWS Lambda. I want RollupJS to do it's thing on some JS and CSS.
I am using Serverless to create the Lambda and everything works locally.
Local dev is Node 10.0.0 (using NVM) and the Lambda is on the node.js 10.x Runtime
Like I said, all works fine locally both running serverless-offline and when just executing the file directly from the command line.
However once it goes into the Lambda, it falls over. This is the error
I have tried
npm rebuild node-sass
and redeployed, but I get the same issue. (nothing seemed to happen on the command line by the way)I also tried
npm rebuild node-sass --force
and loads of npm stuff seemed to happen. But I get the same issue on redeploy.I've seen a few issues around this and most seem to suggest running
npm rebuild node-sass
will fix it. Not sure if I've done it wrong, or if it's a conflict with AWS? If I do run it, what should I be looking for?Any help?
Thanks, Tom