Run Javascript code in Atom using script


#1

Hi. I have downloaded the atom editor and script package and am trying to print the word “Hi” to the console. Right now I have one line of javascript code

console.log(“Hi”);

When I hit Ctrl+Shift+B I get an error message

‘C:\Users\Chase’ is not recognized as an internal or external command,
operable program or batch file.


#2

Did you change the script settings at all?


#3

In the script settings I ran the program using the three options of the drop down menu of the Default Current Working Directory (CWD) Behavior. The three options are

  1. First Project Directory
  2. Project Directory of the script
  3. Directory of the script

When I hit Ctrl+Shift+B with First Project Directory or Directory of the Script selected I get the error

‘C:\Users\Chase’ is not recognized as an internal or external command,
operable program or batch file.
[Finished in 0.052s]

When I hit Ctrl+Shift+B with Project Directory of the Script selected I get the error

Uncaught TypeError: Cannot read property ‘indexOf’ of undefined
C:\Users\Chase Reynolds.atom\packages\script\lib\runner.js:166


#4

Is the script inside C:\Users\Chase Reynolds?


#5

When you say script do you mean the file with the one line of code I am trying to run?

I right clicked the file containing the one line of line code I am trying to run (I named the file YOYO4) and selected “copy full path” and got this

C:\Users\Chase Reynolds.atom\packages\script\YOYO4


#6

Yes. When I’m talking about the package, I will always write it as script.

I right clicked the file containing the one line of line code I am trying to run (I named the file YOYO4) and selected “copy full path” and got this
C:\Users\Chase Reynolds.atom\packages\script\YOYO4

Is this path exactly what you see? Because it’s missing a \ in front of .atom. If it’s not exactly what you see, you need to wrap it in backticks to format it as code.

Most likely, the issue is with the space in your name, and specifically the issue is probably that script is sending off the command without quoting the path, in which case the first contiguous string of characters (C:\Users\Chase) is being read as the command. You should try placing the script somewhere that isn’t underneath Chase Reynolds\ and see if it works then. As for solutions, if this is the case you should open an issue on the script GitHub repo to alert the maintainers of this problem. I use process-palette, which doesn’t send any commands that I don’t explicitly tell it to.