This question already has answers here:
where to destroy knex connection
(3 answers)
Closed 7 months ago.
I have some script on Node.js server.
It's opened some file, do something, and after that i try remove this file from storage with fs.unlink, but i got an error: EBUSY: resource busy or locked, unlink
If i try delete if manually, i got an error:
Screenshot with error
If i stop node.js app, or reload, error disappear, and i can delete this file.
How i can remove this file from Node.js JavaScript runtime, and remove it without error and crashes my app?
UPD:
I just parse .sqlite file trough knex.select("table_name")
And after that, fs.unlink() must remove that .sqlite file
Without seeing the code it's difficult to say, but surely your file is still open. Try fs.close(fd, callback) before fs.unlink. However, I'd think your bug has to do with asynchronously performed code.
Related
I am trying to import a json file from a website using p5.js, and i thought it would be quite easy, however when i tried it i realized the json was actually just in plain text on the page (It is the only thing on the page). I checked chrome web tools to look at index.html, but i was greeted by "(index)", is it a problem with google or am i just going to have to use something else than this?
function preload() {
httpGet('leaderboard.popcat.click', 'json', function(response) {
});
}
//there are the setup and draw functions aswell
I got an error when i ran the code aswell, it was
Error: JSONP request to url failed
here is a picture of the page btw, (the url is leaderboard.popcat.click)
EDIT: The main problem i am having is that there is no file in https://leaderboard.popcat.click/, not the getting of json.
The network tab says no such url exists, and i believe that is because of the fact that i didn't specify a file.
Here is the console output aswell
I solved my issue by starting chrome in no-cors mode or whatever it's called AND using the full path of the website. I got it into no-cors mode by making a shortcut with this link
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --disable-web-security --user-data-dir=~/chromeTemp"
and running it as an administrator
I am trying to load a javascript I created for using it in mongoDB. I've tried many sintaxes as load('path/file') and still the same error as it folows:
> load("/Scripts/logs_js.js")
2020-03-31T17:33:32.671+0200 E QUERY [js] Error: couldn't open file :
#/Scripts/logs_js.js:1:15
#(shell):1:1
2020-03-31T17:33:32.671+0200 E QUERY [js] Error: error loading js file: /Scripts/logs_js.js :
#(shell):1:1
I'm desperate about this error, I've seen people doing the same way as me and it works for them. Thanks everyone beforehand.
I just realized that mongo was correctly opening the javascript file. But in the first line of my javascript there was a cat() function to open a .txt file, and that was the one that couldn't be opened.
First, as I follow the lectures, I deleted "src" folder entirely, but in the browser on the "localhost:8080" page content "Hello There!!!" from index.js file remained intact on the page after refreshing. First oddity.
Researched questions&answers for similar experiences -none. Asked Question 6 days ago, answer- none.
As I continued with the lectures, constructed new "src" folder and brand new "index.js" file. Inside of that file I wrote, following the tutor, an error-driven code which should produce an error in the console.
That code is:
const App = function() {
return <div> Hi! </div>
}
React.render(App);
The expected and never showed error should be:
Uncaught Reference Error react is not defined.
None. Just blank in the console. And the old "deleted" "Hey There!!!" content on the page.
EDIT 2:
When I import the React from 'react', now get a different error.
This error suggests that there is an application already using the Port 8080. This means that, if your app was running in the same port, then, you did not properly stop the server and as a result the app is still running there. You can fix this in one of two ways:
Make sure you have stopped the server completely with CTRL+C
Change the port your app is running in.
I would suggest the first option.
This question already has answers here:
Understanding phaser in java with an example
(3 answers)
Closed 5 years ago.
I want to learn this framework ...
I download last version from github put it intro www folder and i don't see any working file .
Is it strict to use MAMP ?
Being a Unix environment at heart there are more options available on OS X than Windows. But if you'd like an "all in one" approach like WAMP, with a nice clean and easy to use interface, then we'd strongly recommend MAMP. This comes in two versions: one free and one paid for.
Logs :
projects/bomber/
Viewport argument key "minimal-ui" not recognized and ignored.
This folder should sit along-side the Phaser Examples, for example:
/webroot/phaser
/webroot/phaser-examples
I use relative path .
Error log from tree examples :
[Error] Failed to load resource: the server responded with a status of
404 (Not Found) (phaser.js, line 0)
localhost/new_prototype_slot/STARTER/phaser-examples-master/examples/_site/js/phaser.jsFailed
to load resource: the server responded with a status of 404 (Not
Found)
Any suggestion who to start example in localhost !
Download brackets.io text editor, open index.html file, then click "live preview" button?
This question already has answers here:
getting the raw source from Firefox with javascript
(3 answers)
Closed 8 years ago.
I'm not using Selenium to automate testing, but to automate saving AJAX pages that inject content, even if they require prior authentication to access.
I tried
tl;dr: I tried multiple tools for downloading sites with AJAX and gave up because they were hard to work with or simply didn't work. I'm resorting to using Selenium after trying out WebHTTrack (whose GUI wasn't able to start up on my Ubuntu machine + was a headache to provide authentication with in interactive-terminal mode), wget (which didn't download any of the scripts of stylesheets included on my page, see the bottom for what I tried with wget)... and then I finally gave up after a promising post on using a Mozilla XULRunner AJAX scraper called Crowbar simply seg-faulted on me. So...
ended up making my own broken thing in NodeJS and Selenium-WebdriverJS
My NodeJS script uses selenium-webdriver npm module which is "officially supported by the main project" to:
provide login information + do necessary button-clicking & typing for authentication
download all JS and CSS referenced on target page
download target page with original JS/CSS file links change to local file paths
Now when I view my test page locally I see double of many page elements because the target site loads HTML snippets into the page each time it's loaded. I use this to download my target page right now:
var $;
var getTarget = function () {
driver.getPageSource().then(function (source) {
$ = cheerio.load(source.toString());
});
};
var targetHtmlDest = 'test.html';
var writeTarget = function () {
fs.writeFile(targetHtmlDest, $.html());
}
driver.get(targetSite)
.then(authenticate)
.then(getRoot)
.then(downloadResources)
.then(writeRoot);
driver.quit();
The problem is that the page source I get is the already modified page source, instead of the original one. Trying to run alert("x");window.stop(); within driver.executeAsyncScript() and driver.executeScript() does nothing.
Perhaps using Curl to get the page (you can pass authentication in the command) will get you the bare source?
Otherwise you may be able to turn off JavaScript on your test browsers to prevent JS actions from firing.