question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Windows Temp file not working electron

See original GitHub issue

Operating System

  • Linux
  • Windows 7
  • Windows 10
  • MacOS
  • other:

NodeJS Version

  • 0.x
  • 4.x
  • 6.x
  • 7.x
  • other: 8.6

Tmp Version

TBD:Enter tmp version here newest

Expected Behavior

TBD:What have you expected tmp to do? correct temp file.

Experienced Behavior

TBD:What did actually happen?

It generates this file:

let fileName = tmp.tmpNameSync();
undefined\temp\tmp-3476obo4mLnOL8Bp

Then i trying to write to this file:

fs.writeFileSync(fileName, new Buffer(result.data));
no such file or directory, open 'C:\Users\xxx\xx\app-1.0.2\undefined\temp\tmp-3476obo4mLnOL8Bp'

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
do-webcommented, Sep 22, 2018

This is working now: tmp.tmpNameSync({ dir: app.getPath('temp') })

0reactions
silkentrancecommented, Feb 6, 2020

This was never fixed, at least not correctly.

It will also break with the changes for #207 and the way that the dir option is being treated, which can no longer be an absolute path outside of the system’s default.

The correct behaviour should be for _getTmpDir() to throw an exception if the os.tmpDir() cannot be resolved as a path using path.resolve().

From the official electron docs https://www.electronjs.org/docs/all

Avoid platform-dependent code:

Use path.join() to concatenate filenames.
Use os.tmpdir() rather than /tmp when you need to reference the temporary directory.

So os.tmpdir() should be set and working around using app.getPath(‘temp’) must not be used.

Read more comments on GitHub >

github_iconTop Results From Across the Web

In Electron app how do you reference the temp path?
Learning Electron I'd like to do some file processing after a drag and drop. On a Mac the equivalent for tmp is a...
Read more >
WDAC How to allow .tmp.node file by Electron app?
Hi all, I'm facing an issue with .tmp.node file that executed by an application called Ledger Live and written by Electron.
Read more >
Create a temp directory for your app in Node.js
When working with Node.js, you might need to create a temporary folder for your app. Here's how to do it.
Read more >
Options | electron-packager
Functions to be called after your app directory has been copied to a temporary directory. Note: afterCopy will not be called if the...
Read more >
How I Fixed: Electron builder rcedit-x64.exe": file does not exist
cannot execute cause=exec: "C:\\Windows\\TEMP\\electron-builder-cache\\winCodeSign\\winCodeSign-2.6.0\\rcedit-x64.exe": file does not exist ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found