are you sure you successfully install npm install @nesk/rialto ?
Cannot find module '@nesk/rialto'
Hello, I am sure I have missed something about it, but I can't find it how? So I have decided to post it here.
I have installed, puphpeteer and rialto to my project file, as it is described. Then I have used the typical example without changing in my controller file.
use Nesk\Puphpeteer\Puppeteer;
class myclass extends Controller
{
public function dofunction()
{
$puppeteer = new Puppeteer();
$browser = $puppeteer->launch();
$page = $browser->newPage();
$page->goto('https://example.com');
$page->screenshot(['path' => 'example.png']);
$browser->close();
}
}
It was said in rialto documents, I had to do two things. One is this class below, so I have put it in the same controller file with the above function.
use Nesk\Rialto\AbstractEntryPoint;
class FileSystem extends AbstractEntryPoint
{
public function __construct()
{
parent::__construct(__DIR__.'/FileSystemConnectionDelegate.js');
}
}
Then I have created FileSystemConnectionDelegate.js file and put it in the same namespace where my controllers are. The content of FileSystemConnectionDelegate.js is so:
const fs = require('fs'),
{ConnectionDelegate} = require('@nesk/rialto');
module.exports = class FileSystemConnectionDelegate extends ConnectionDelegate
{
handleInstruction(instruction, responseHandler, errorHandler)
{
// Define on which resource the instruction should be applied by default,
// here we want to apply them on the "fs" module.
instruction.setDefaultResource(fs);
let value = null;
try {
// Try to execute the instruction
value = instruction.execute();
} catch (error) {
// If the instruction fails and the user asked to catch errors (see the `tryCatch` property in the API),
// send it with the error handler.
if (instruction.shouldCatchErrors()) {
return errorHandler(error);
}
throw error;
}
// Send back the value returned by the instruction
responseHandler(value);
}
}
At first the Node was not recognised therefore, I had to change 'executable_path' => 'c:\Nodejs\node.exe' and it seems alright.
However now, I am getting the error below error:
Nesk\Rialto\Exceptions\Node\FatalException
Cannot find module '@nesk/rialto' Require stack: - C:\Users\user\Desktop\project-v1\vendor\nesk\puphpeteer\src\PuppeteerConnectionDelegate.js - C:\Users\user\Desktop\project-v1\vendor\nesk\rialto\src\node-process\serve.js
Throwing from this file: C:\Users\user\Desktop\project-v1\vendor\nesk\rialto\src\ProcessSupervisor.php:307
It says it cannot find module '@nesk/rialto' . and I thought I have installed the rialto package with
composer require nesk/rialto npm install @nesk/rialto
I can't solve this problem. Is there something missing on my side?
Please or to participate in this conversation.