I was successfully able to register a custom protocol using npm i protocol-registry. Here is the code for the same :
ProtocolRegistry.register({
protocol: "mydemoprotocol",
command: `node ${path.join(__dirname, './app_code.js')} $_URL_`,
override: true,
terminal: true,
script: false,
}).then(async () => {
console.log("Registered Successully...");
});
But when I enter mydemoprotocol:// in the browser, I get the following error :
I am trying to load faceapi models in app_code.js. Here is the code for the same :
await faceapi.nets.ssdMobilenetv1.loadFromDisk('/models')
await faceapi.nets.faceLandmark68Net.loadFromDisk("./models"),
await faceapi.nets.faceRecognitionNet.loadFromDisk("./models"))
All the files required to load the model are present in the same directory as app_code.js. Why am I getting error for the path 'C:\WINDOWS\system32\' when I am trying to run the file from D: Drive.
Any help will be grateful. Thanks.
Related
I run a gulp task using NodeJS module browser-sync as below.
=== File gulpfile.js ===
let browserSync = require('browser-sync').create();
gulp.task('browser-sync', function(){
browserSync.init( {
open: true,
injectChanges: true,
proxy: 'https://generalgulp.devsunset',
host: '192.168.1.76',
serveStatic: ['.'],
https: {
key: 'C:\\WebProjects\\GeneralGulp\\resources\\certificates\\server-generalgulp.key',
cert: 'C:\\WebProjects\\GeneralGulp\\resources\\certificates\\server-generalgulp.crt'
}
});
});
=== ===
My local project information is as below (I use latest up to current post date):
Node version: 17.1.0
NPM versions: 8.1.3
gulp: 4.0.2
NPM module browser-sync: 2.27.7
I run the browser-sync task. The output looks good.
==>
Using gulpfile C:\WebProjects\GeneralGulp\gulpfile.js
[Browsersync] Starting 'browser-sync'...
[Browsersync] Proxying: https://generalgulp.devsunset
Access URLs:
Local: https://localhost:3000
External: https://192.168.1.76:3000
UI: http://localhost:3001
UI External: http://localhost:3001
==>
I already add the SSL certificate for this domain to trusted root. I also have DNS records pointing from this domain ( https://generalgulp.devsunset ) - IP addresses ( 127.0.0.1 & 192.168.1.76)
I can access the site from both local & external address.
However, when I try to access the local resources using proxied domain ( https://generalgulp.devsunset
) , it gets an HTTP 403 :
Access to <my_custom_domain> was denied. You are not authorize to
view this page
I suppose when running my gulp "browser-sync" task, it will translate the custom domain to the https://localhost:3000 or https://192.168.1.76:3000
I have followed exactly the documents of https://browsersync.io/docs . I have also made an attempt with all solutions I could find. Those solutions led me to the gulp task that I wrote at the beginning.
I would appreciate if you can suggest me which things I should do further to troubleshoot why does my browser-sync cannot “proxy” my domain? Is there any parameter missing in my Gulp task?
Thanks !
I have modified the "proxy" parameter as below and it works when i access the proxied domain with given port:
(for my case is http(s)://generalgulp.devsunset:3000 )
`gulp.task('browser-sync', function(){
browserSync.init( {
open: true,
injectChanges: true,
proxy: 'generalgulp.devsunset',
host: '192.168.1.76',
serveStatic: ['.'],
https: {
key: 'C:\\WebProjects\\GeneralGulp\\resources\\certificates\\server-generalgulp.key',
cert: 'C:\\WebProjects\\GeneralGulp\\resources\\certificates\\server-generalgulp.crt'
}
});
});
`
This is a temporary acceptable solution regarding to the current question scope.
However, What i expect is the browser-sync will auto-forward traffic from custom domain ( http(s)://generalgulp.devsunset ) to : ( http://192.168.1.76:3000 ).
Does browser-sync allow users to do it ?
I've got a task to deploy some stylesheets out to a server using FTP and about 80% of the time I get this error,
Error: write EPIPE
at _errnoException (util.js:1022:11)
at WriteWrap.afterWrite [as oncomplete] (net.js:880:14)
I'm using vinyl-ftp to upload the file as seen in the code here,
var conn = ftp.create({
host: 'host',
user: 'user',
password: 'pass',
parallel: 10,
idleTimeout: 10000,
reload: true,
secure: true,
secureOptions: {rejectUnauthorized: false},
log: gutil.log
});
// What files to transfer over (can be used in case there are more files to be uploaded in the future)
var globs = [
localDir + '/' + jobName + 'Default.css'
];
gutil.log("Local File: " + globs[0]);
var remoteDir = '/' + environment + '/css/' + clientName + '/' + jobName;
gutil.log("Remote Dir: " + remoteDir);
return gulp.src(globs, {buffer: false}).pipe(conn.dest(remoteDir));
The server that I'm uploading to is using FTP-SSL (Explicit AUTH TLS). I'm not sure if that's what's causing the issue but I've tried catching the error and adding an onerror event to process.stdout but none of them work. When the error does trip it uploads an empty file to my server.
It'd be great to find a solution to this or better yet a different FTP package.
Edit 1: I'm on Windows.
Finally just said screw it and changed what module I was using. node-ftp only throws the EPIPE error about 5% of the time compared to the original 80%. You can also catch the error which is useful because I catch it and try to upload the file again.
ENOENT - but my file is just in the same directory ...
Hi all I try to sent a file, birds.mp3, to my Google Drive using API. The file got to be reached by a function to be sent.
Despite that the file I try to send is just in the same folder that the code concerned, my console return me :
events.js:183
throw er; // Unhandled 'error' event
^
Error: ENOENT: no such file or directory, open './birds.mp3'
Here my tree :
-- folder
|-- birds.mp3
|-- quickstart.js
Here my quickstart.js
module.exports.insertDrive = function (req) {
console.log("callback reached.")
var url = req.body.url;
var folderId = 'id';
var fileMetadata = {
'name': req.body.word,
parents: "id"
};
var media = {
mimeType: 'audio/*',
body: fs.createReadStream("./birds.mp3") // PATH FUNCTION HERE
};
drive.files.create({
resource: fileMetadata,
media: media,
fields: 'id'
}, function (err, file) {
if (err) {
// Handle error
console.error(err);
} else {
console.log('File Id: ', file.id);
}
})};
I can't figure out why my file can't be reached. I have try several tricks like path.resolve and all, I have try to push my birds.mp3 in several folder if any, but that have failed.
Thanks.
If you're trying to load a file from the same directory as the current module and pass that to the Google API, then use __dirname instead of ./. The ./ uses the current working directory which will depend upon how the overall program was invoked and will not point at your module directory.
So, if the intended file is in the same directory as your module, then change this:
fs.createReadStream("./birds.mp3")
to this:
fs.createReadStream(path.join(__dirname, "birds.mp3"));
I am trying to learn Appium, using the instructions given in the documentation:
http://appium.io/docs/en/about-appium/getting-started/?lang=en
I have put this code into a file called AppiumTest.js
const wdio = require('webdriverio');
const opts = {
port: 4723,
desiredCapabilities: {
platformName: "Android",
platformVersion: "8.0",
deviceName: "Pixel_API_26",
app: "C:/Users/SStaple/AppData/Local/Android/Sdk/ApiDemos-debug.apk",
automationName: "UiAutomator2"
}
};
const client = wdio.remote(opts);
client
.init()
.click("~App")
.click("~Alert Dialogs")
.back()
.back()
.end();
I am running it from the Node.js command prompt, using the command: node AppiumTest.js, after starting the Appium Server. It was also necessary to have an Android 8 emulator running.
(Appium Server v1.7.1)
I am getting an output in the Appium Server window. There are a number of errors. The first error shown is this:
Error "Command 'C\:\\Users\\SStaple\\AppData\\Local\\Android\\Sdk\\build-tools\\26.0.2\\aapt.exe d badging C\:\\Users\\SStaple\\AppData\\Local\\Programs\\appium-desktop\\resources\\app\\node_modules\\appium\\node_modules\\appium-uiautomator2-driver\\uiautomator2\\appium-uiautomator2-server-v0.1.8.apk' exited with code 1" while getting badging info
I have tried running this command on its own in the Command Prompt:
C:\Users\SStaple\AppData\Local\Android\Sdk\build-tools\26.0.2\aapt.exe d badging C:\Users\SStaple\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\appium-uiautomator2-driver\uiautomator2\appium-uiautomator2-server-v0.1.8.apk
The result I get here is this:
W/zipro (13656): Error opening archive C:\Users\SStaple\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\appium-uiautomator2-driver\uiautomator2\appium-uiautomator2-server-v0.1.8.apk: Invalid file
ERROR: dump failed because no AndroidManifest.xml found
Any ideas?
Update 28/12/2017 - I found the solution!
The file in question looked suspect. It was 0Kb in size!
I downloaded the apk file from https://github.com/appium/appium-uiautomator2-server/releases and used that instead.
This one is 1,518 KB in size.
(Apparently there is some problem with npm not putting that apk file into the right place while beta is installed.)
Having fixed that, I can move on to the next problem!
Its a known issue with apk signing.
You can start with trying to update dependencies:
npm install appium-uiautomator2-driver
npm install appium-adb
If it didn't help, there is more you can try (but that was for Linux):
modify
./node-v6.11.4-linux-armv7l/lib/node_modules/appium/node_modules/appium-adb/build/lib/tools/apk-signing.js so it would return a true even if it looks not signed.
case 20:
context$1$0.prev = 20;
context$1$0.t0 = context$1$0’catch’;
_loggerJs2[‘default’].debug(“App not signed with debug cert.”);
return context$1$0.abrupt(‘return’, true);
Our application is developed using electron framework. it is a standalone application. I have seen that spectron is the framework which is used to automate electron application. but i am not sure whether it is applicable for desktop application. Please confirm the same.
I have installed nodejs and spectron.
I have written a code launch application as mention in the following site
https://electron.atom.io/spectron/
File Name : First.js
var Application = require('spectron').Application
var assert = require('assert')
var app = new Application({
path: 'C:\Users\ramass\AppData\Local\Programs\ngsolutions\ngsolutions.exe'
})
app.start().then(function () {
// Check if the window is visible
return app.browserWindow.isVisible()
}).then(function (isVisible) {
// Verify the window is visible
assert.equal(isVisible, true)
}).then(function () {
// Get the window's title
return app.client.getTitle()
}).then(function (title) {
// Verify the window's title
assert.equal(title, 'My App')
}).then(function () {
// Stop the application
return app.stop()
}).catch(function (error) {
// Log any failures
console.error('Test failed', error.message)
})
i have tried to run the script using command
node First.js
But i am getting error saying that
C:\spectronprgs>node First.js
Error: Cannot find module 'spectron'
Please let me know whether I am going towards right path
how to launch .exe file using spectron framework
how to run the script
run the following from the command line.
npm install --save-dev spectron
Then see if you can find the module. You never mentioned in your post how you installed spectron.