-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error: Cannot find module 'image'. Running Laravel on localhost. #21
Comments
That's odd, I wouldn't expect to see |
Also no, you should be able to run it from localhost just fine! |
app/Sidecar/OgImage.php <?php
namespace App\Sidecar;
use Hammerstone\Sidecar\LambdaFunction;
class OgImage extends LambdaFunction
{
public function handler()
{
// Define your handler function.
// (Javascript file + export name.)
return 'resources/lambda/image.handler';
}
public function package()
{
// All files and folders needed for the function.
return [
'resources/lambda',
];
}
} resources/lambda/image.js // const { createCanvas } = require("canvas");
exports.handler = async function (event) {
console.log(event);
// const canvas = createCanvas(1200, 630);
// const context = canvas.getContext("2d");
// context.font = "bold 70pt Helvetica";
// context.textAlign = "center";
// context.fillStyle = "#3574d4";
// // Read the text out of the event passed in from PHP.
// context.fillText(event.text, 600, 170);
// // Return an image.
// return canvas.toDataURL("image/jpeg");
}; routes/web.php <?php
use Illuminate\Support\Facades\Route;
use App\Sidecar\OgImage;
Route::get('/', function () {
return view('welcome');
});
Route::middleware(['auth:sanctum', 'verified'])->get('/dashboard', function () {
return view('dashboard');
})->name('dashboard');
Route::get('/ogimage', function () {
return OgImage::execute([
'title' => 'Executing Functions',
'url' => 'https://hammerstone.dev/sidecar/docs/main/functions/executing',
'template' => 'docs/sidecar'
]);
}); |
Yup, on Windows 10. I'll check on my 2nd Windows PC also to see this is happening or not. |
@nazrinnoorzan thanks for the report. I'll try to add a Windows machine to the GitHub actions build so I can test it there. I don't really understand where that would be coming from. It looks like it's also removing the |
I have this same problem on Windows 11. Isolated the problem to the |
As @wilsenhc said the problem is in
|
Is this can only be used with Vapor?
I've setup a local Laravel and follow your code implementation example, and I don't have any error when running the command php artisan sidecar:deploy --activate
But on the /ogimage, I got error saying -
Lambda Execution Exception for App\Sidecar\OgImage: "Error: Cannot find module 'image' Require stack: - /var/runtime/UserFunction.js - /var/runtime/index.js. [TRACE] Runtime.ImportModuleError: Error: Cannot find module 'image' Require stack: - /var/runtime/UserFunction.js".
The text was updated successfully, but these errors were encountered: