MenuSettings and looks / The Working Folder

Docs / Settings and looks

The Working Folder

Every Node Run works in one folder, the Working Folder. The files your Snippets write are kept there.

On this page

What it is

A Node Run starts in the Working Folder. A file your Snippet writes by a relative path, such as fs.writeFileSync('notes.txt', text), or beside __dirname, lands there. It stays after the Run and after you quit, until you empty the folder.

  • Every Node Snippet uses the same folder, so one Snippet can read a file another one wrote.
  • Everything in it is yours: JSpark keeps nothing of its own there once a Run ends. In a Working Folder you chose in Settings, it adds one node_modules link, so your Snippets can import installed packages.
  • It is where relative paths go, not a limit. A Snippet can still read and write anywhere you can. See Outside Access.

Open it

  • Choose Run → Reveal Working Folder.
  • Or open Settings → About and click Reveal in Finder under Working folder.

Settings shows where the folder is and how much it holds. Copy path, beside the path, copies it.

Settings, About: the Working folder’s path with Copy path, its size, and the three things you can do with it.

Change or empty it

Change it

  1. In Settings → About, click Change… under Working folder.
  2. Pick an empty folder, or make a new one in the window that opens.

JSpark moves everything from the current folder into the new one, and Node Runs work there from then on.

It refuses a folder that isn’t empty, a folder it can’t write to, and a folder inside the current one or holding it. It says why, and nothing is moved.

If the folder you chose is missing when JSpark starts, for example on a drive that isn’t connected, JSpark goes back to its own folder and tells you. Choose your folder again in Settings when it is back.

Empty it

  1. In Settings → About, click Empty… under Working folder.
  2. Click Empty to confirm.

Every file your Snippets wrote there is deleted. This can’t be undone. The button is greyed out while the folder is empty. A Run still running keeps the file it needs.

Run in a folder of your own JSpark+

In JSpark+, one Node Snippet can run in a folder you choose, such as a project of yours, instead of the Working Folder. Use it to import your own modules, as in import { slugify } from './utils.js', or to read a project’s files by relative path.

  1. Open the Node Snippet.
  2. Choose Run → Run in Folder….
  3. Pick a folder, or make a new one, and click Run Here.

The footer names the folder, and every Node Run of that Snippet works there, the Timeline included:

  • process.cwd() is the folder.
  • A relative import, require or fs path starts from the folder.
  • A package import looks in the project’s own node_modules first, then in the packages installed in JSpark. See Packages.
The footer says where this Snippet runs. The × sends it back to the Working Folder.

To go back, click the × after the folder’s name: Run in the Working Folder instead. The other Snippets always run in the Working Folder.

Good to know

  • The Snippet waits for you to press Run: Run as you type pauses for it, because its Runs work with your real files. The rail says Uses a folder of yours, so auto-run is paused. See Outside Access.
  • While a Run works, JSpark writes the Snippet as a hidden file beside your code, named like .jspark-run-1.mjs (or .cjs), and removes it when the Run ends. If JSpark quits in the middle of a Run, it removes the file at the next launch. In a Git project, add .jspark-run-* to your .gitignore. JSpark puts nothing else in your folder.
  • The folder is kept on the tab, also after you quit and open JSpark again. It is never saved in the Library or an export, because a path means nothing on another computer.
  • If the folder is gone, for example on a drive that isn’t connected, the Snippet runs in the Working Folder and the console says The folder … isn’t there any more, so this ran in the Working Folder.
  • Run in Folder… is for Node Snippets. It isn’t offered in the Timeline: leave it first.

In JSpark, choosing Run in Folder… says that running in a folder of your own needs JSpark+. If a Yearly key lapses, a Snippet already set to a folder keeps running there; setting another folder asks for JSpark+.

The pictures show JSpark on a Mac. On Windows, the window buttons are at the top right, the menus are in theMenu button at the left end of the tabs, and shortcuts use Ctrl where a Mac uses ⌘. The rest works the same way.

Esc

Type to search every docs page.

JSpark is downloading

When you open JSpark-Setup.exe, Windows may stop it once, because the installer isn’t code-signed yet. If the file came from jspark.app:

A blue Windows box, “Windows protected your PC”: Microsoft Defender SmartScreen prevented an unrecognised app from starting. Under it, the link More info, and the button Don’t run.

1Click More info.

The same box after More info: Application JSpark-Setup-1.4.0.exe, Publisher Unknown publisher, and the buttons Run anyway and Don’t run.

2Then click Run anyway.

You see this only once: updates install inside the app. More in Install JSpark.