node webkit doesn't launch with '#' in folder name - exe

I have the following node webkit version
nw.js v0.12.2
On Windows,when I run the nw exe from a folder which has '#' in it.e.g
C:\Users\user\Downloads\ #321\...\viewer\nw.exe
it opens a window with the list of files and directories in Downloads folder. Any idea why it behaves so ?
Also on MacOsx I am unable to launch it if I have a '#' in the directory name.
The error got is
Uncaught ReferenceError:require is not defined
Not allowed to load local resource:
I understand in both cases that special character is causing the problem but is this some sort of a command to Node webkit ? If there is any such reference it would be helpful to know that.

Related

How to add Node.js path in WebStorm using Linux

I am using WebStorm 19.3.1 on Linux Mint Cinnamon 19. I am trying to add a path for node.js to debug my code in WebStorm. The path for node.js is /usr/bin/nodejs, when I go to this directory I can find nodejs file there, but when I open WebStorm and try to access this path from there, It doesn't show node.js file inside.
The permissions for node.js are Read And write, should I add execute too for the root?
If you know how to solve the problem please help me to fix it out.
Thanks in advance.
I've seen people on internet simply opening the path from Webstorm, but in my case it doesn't show.
https://www.youtube.com/watch?v=U7ydvEh9WLQ check out this link.
//There is no code actually
Expecting to have configurations correctly set up)

Differences in nodejs paths between linux and windows

I have create-react-app project and I have a scss file in it.
Inside this file, I have a string like image: url("src/assets/icons/icon1.png");
When I run npm run start in windows everything is ok, but whene i run the same in WSL it gives an 'icon1 file not found' error. It join current file path with target file path.
I think there is a difference between working with start of a path in windows and linux, but I can't find any info about that.
What the differences between working with path starts in this systems and is there any way to use this code in linux without adding / in to beginning of the path?

My eslint is not working in windows with the *.js path argument

I have a node project that is using eslint and it seems to run fine on mac but gives the following command prompt error in a windows machine 'no such file or directory. stat c:\projects\*.js
It doesn't seem to like the *.js argument. If I remove *.js and just point to the directory it works fine. Alternatively, if I explicitly point to a specific file with the full path, that also works.
Here's the lint npm command I'm using
node_modules/.bin/eslint ./*.js ./**/*.js
What makes the *.js incompatible on the windows machine?

setting environment variables for node.js child process

I have a node webkit app, part of which involves using child processes in node to call pdftk (a separate command line program).
I don't want my users to have to install pdftk or use the command line, so I included pdftk in the packaged version of the node webkit app. If I run this packaged app from the command line, it works fine - and I assume that's because it's using the version of pdftk that's installed on my computer, not the one packaged with the app.
When I try to launch the app by double clicking on an icon in the gui, as I'd want a user to be able to do, I get a node.js error - child process ENOENT. I think that's because when launched through the gui, it doesn't inherit the environment variables (including PATH) from my command-line environment.
I know I can set environment variables as an option when I call the child process, but haven't been able to figure out how to do that correctly. I'm not sure what variable I should set, or what I should set it to. I suppose I'm not sure if it's even possible to call pdftk from within the packaged app, or if I would need to have the user install it on their own computer. Any help would be much appreciated.
I think this might not be about environment variables. I guess when you run from the command line your current working directory (CWD) is where the app is. And I think you set the path to pdftk relative to the node script. When you double click (a shortcut) the current working directory and the path where the node script is located are different so relative paths don't work as expected.
When you use relative paths, always use __dirname to get the path the node script is on and use it to set path to the pdftk file. The path.resolve function can be useful when doing this. Read path.resolve documentation
I strongly recommend you to check this question and answers
How do I get the path to the current script with Node.js?
What is the difference between __dirname and ./ in node.js?

Command "docpad run" is getting error: "module" is undefined

I've migrated my configurations from docpad.coffee to docpad.js (personal preference on using plain Javascript)
Since then, I'm not being able to execute the command
docpad run
And I'm keep getting this error:
I've validated my configurations against JSLint and made sure there's no syntax error.
I'm good to go with docpad.coffee, but it'd be great if someone could help me on fixing this
You can use docpad.cmd run instead of docpad run to distinguish between the local docpad.js and the global npm-installed docpad.cmd.
This is because windows recognises the ".js" extension as a javascript file and tries to run your docpad.js file when you issue the "docpad run" command. Windows script host is what is used by windows to run js files natively (so actually nothing to do with node or docpad itself). The reference to "module" in the error message is because that is the first line of the docpad.js file and the windows script host doesn't know what "module" is. You can just rename your docpad.js file to .coffee (I believe all javascript is valid coffee script) and then the windows message will disappear.
Edit: I've just went and tested this on the docpad skeleton which has a docpad.js file instead of docpad.coffee. Simply renaming it to docpad.coffee does indeed solve the problem. Renaming it back to .js then causes the 'Windows Script Host' error message to appear when the "docpad run" command is issued.

Resources