I installed sqlite3 like this:
npm install sqlite3
It succeded without any errors. Now, if I want to execute sqlite, I get the Following Exception:
It says "'module' is undefined". Am I missing something? I tried the exact same thing on OpenSUSE and it worked as expected.
The first problem is you're trying to run a node.js script using Windows' JScript implementation (this is the default file association in Windows). You need to run the script with node in one way or another. One way to do this is via the command prompt with node myscript.js.
The second problem is that you're trying to execute sqlite3.js which doesn't actually do anything except export the database client. Instead you need to write your own script (that lives in the parent directory of node_modules) that require()'s sqlite3 and uses that.
Related
I'm currently working on a project with Electron 9.0.4 and Electron-Builder 22.8.0 and am faced with a problem that doesn't seem too difficult but there isn't a valid solution online! (At least I couldn't find it)
I have my main program that does all of the UI tasks, and a command line script that does some backend. The reason I have this command line script is so that I can run certain parts of the application without opening the window itself. Everything works fine on my computer. After running npm link, my CL script is added to my environment variables and I can just run it from the console. However, when I try to build with electron-builder, the problem occurs.
If I use my Setup.exe on another computer, the command line script just won't be added to the environment variables and I couldn't find instructions on how to do this in the electron, nodejs, or electron-builder documentation. What I found was a suggestion on another question to add npm -g install as a post-install script, but that had no effect either.
Someone else suggested adding npm link as a post-installation script, but firstly if I am not mistaken this function is not intended for production and secondly it created an infinite loop as npm link triggered the post-installation script over and over again.
Thats how the script is added to the project
"bin": {
"command-name": "/cl.js"
}
Any help is appreciated!
Since I couldn't find a direct solution to my problem and didn't want to look any further for a solution while being able to take a different approach.
I decided to take a step back and look for another method to solve my problem I came to the conclusion that I didn't really need to add a script to the command line. My solution was to look for a certain argument when starting the regular application.
if (process.argv.includes("cli")) { /* Do commandline stuff */ }
When the custom argument is found, I simply run the script that should've been run from the command line. Using this approach, you can create a shortcut to my executable that contains the custom argument and then instead of the application it runs the command line script.
I have Node.js + NPM installed; I can run node -v in my console and get back the current version.
I have also tried using NVM Windows as a Node.js version manager and can run both node -v and npm -v there as well.
HOWEVER, when trying to use another framework like Gulp or Ionic or whatever, I keep getting the error:
'node' is not recognized as an internal or external command,
operable program or batch file.
node is obviously a cmdlet as I can run node -v.. but somehow my other frameworks are no longer able to find it.
Path is correct and everything looks good.
What am I missing here?
The program ConEmu for windows terminal management wasn't pulling or allowing programs to access the paths through subcalls or something it seems. I tested with CMD and Powershell respectively and both worked as expected.
I couldn't get ConEmu to seemingly pass these path to subroutines.. so I uninstalled it and found an alternative called Cmder that is built on ConEmu and it was able to pick them up just fine.
I don't know specifically if it was just a setting in ConEmu I couldn't find or if I needed to manually add these--but happy knowing Cmder just does it automatically.
I'm trying to use this tool: https://github.com/mapbox/node-mbtiles/wiki/Post-processing-MBTiles-with-MBPipe
I've installed mbtiles with npm install -g mbtiles. I've also installed it locally (in the dir I'm working in) with just plain npm install mbtiles.
That part worked (I was able to download the files), but now according to the readme I can just start entering in commands like
mbpipe 'pngquant 64' myMbTilesFile.mbtiles and it's supposed to work?
Umm... don't I have to run a specific script file (like "node scriptfile.js")? This is acting like I can call functions within a script and pass it variables? I can tell you, as the user mentioned, that 'mbpipe' is within the utils.js file I have.... but how am I supposed to use it?
when I enter in the above command, I of course get "mbpipe: command not found"
So... what are they talking about?
I installed nodejs 64bit on my windows8.
NOTE: By install, I mean I used node-v0.10.35-x64.msi andn its Windows8 for SurfacePro3.
I am not familiar with add PATH. What exactly should add I add and how I run it after I added it?
However, nodejs will not be available outside of its own installation folder.
For example,
if I installed it at /www/test directory, then it will not available either in www or any level after test, like, /www/test/anothertest. Only /www/test will have node running.
I test it by write node -v on /www/test directory in command prompt. I consider its available when it returns me the node version number. When it is not recognized, it will say 'node' is not recognized as an internal or external command...'
I insta
Restart your computer always fix everything....
Yes it did now everything works lol
I'm trying to run PhantomJS from a Grails application running on a Tomcat 7 instance on Linux (Ubuntu 13.04).
I'm sure PhantomJS is installed correctly because I can execute it from the command line. I'm using it to make a screen capture of a web page (http://phantomjs.org/screen-capture.html).
When I run the command from the command line, it works great, using user root:
phantomjs /home/user/captureScreen.js "http://xx.xx.xx.xx/chart" "/home/user/07012014050636114.png"
I believe there is no need to share the JS code since it's working fine from the command line.
The problem is that when I run the same command from the web-app (Grails), it just returns with a 0 value, which tells me everything ran fine, but it's not creating the PNG file neither returning an error.
I'm calling the command from Groovy, this way:
String path = "phantomjs pathToJs.... etc"
def process = path.execute()
process.waitForOrKil(5000) // This runs in 1 to 2 seconds in the command line
println process.exitValue()
I tried adding write permissions to the tomcat7 user to the folder where the JS file and where the image is written but still it didn't work but I still believe it's something related to permissions
Any thoughts?
Thanks!
As for command execution, we experienced problem in Grails applications concerning pure string notation. Using the array syntax
["/usr/binphantom/js","/home/user/captureScreen.js","http://xx.xx.xx.xx/chart","/home/user/07012014050636114.png"].execute()
made the thing work. I think it has to do with shell expansion which differs on how strings are handled in Groovy.