# InDesign file system: writeFile works from an .idjs script, not from a plugin

**URL:** <https://forums.creativeclouddeveloper.com/t/indesign-file-system-writefile-works-from-an-idjs-script-not-from-a-plugin/9203>\
**Category:** InDesign\
**Tags:** filesystem, uxp, javascript, indesign\
**Created:** [February 8, 2025, 2:44pm UTC](https://forums.creativeclouddeveloper.com/t/indesign-file-system-writefile-works-from-an-idjs-script-not-from-a-plugin/9203 "2025-02-08T14:44:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![MicheleID](https://avatars.discourse-cdn.com/v4/letter/m/e19adc/32.png) [@MicheleID](https://forums.creativeclouddeveloper.com/u/MicheleID)\
**Post date:** [February 8, 2025, 2:44pm UTC](https://forums.creativeclouddeveloper.com/t/indesign-file-system-writefile-works-from-an-idjs-script-not-from-a-plugin/9203/1 "2025-02-08T14:44:41Z")

</div>

The problem is simple - I created an InDesign script (V8 engine - .idjs) which writes to a file (see code below). When I run the code code from a .idjs script, it works well. When I run it from an InDesign plugin, I get the error: ‘Route not found’.#@$%µ§  
The old ESTK has the File class which works well. The problem is that it cannot be used in a plugin as the plugin uses the V8 engine which does not support the File class.  
I encounter the same problem when using the writeFileSync method.  
I’ve dedicated a lot of time trying to write to a file from an InDesign plugin. Would anyone have a solution?  
CODE:  
await WriteToFile(“some text”, ‘a’);  
async function WriteToFile(text, mode) {  
try {  
await fs.writeFile(“D:/Perso/Books/InDesign/newFile.txt”,text, {flag:mode, encoding: “utf8”});  
} catch(e) {  
DisplayMsg("WriteToFile ERROR: " + e); // Dialog box to display a message  
}  
} // WriteToFile

---

<div class="post-metadata">

**Author:** ![MicheleID](https://avatars.discourse-cdn.com/v4/letter/m/e19adc/32.png) [@MicheleID](https://forums.creativeclouddeveloper.com/u/MicheleID)\
**Post date:** [February 8, 2025, 4:24pm UTC](https://forums.creativeclouddeveloper.com/t/indesign-file-system-writefile-works-from-an-idjs-script-not-from-a-plugin/9203/2 "2025-02-08T16:24:00Z")

</div>

As I search this forum for pointers on the problem I was having, I discovered what seems to be an interesting conclusion. It seems that Adobe provides two file systems - one which works with V8 engine scripts:  
const fs = require(“fs”);  
and one which works with plugins:  
const fs = require(“uxp”).storage.localFileSystem;  
Here is the code to write to a file from a plugin:  
async function WriteToFile(fileName, text, mode, dir) {  
try {  
const pluginDataFolder = await fs.getDataFolder();  
const file = await pluginDataFolder.createFile(“output.txt”, { overwrite: true });  
await file.write(text, { append: false });  
var nativePath = file.nativePath;  
} catch(e) {  
DisplayMsg("WriteToFile ERROR: " + e);const fs = require(“fs”);  
return;  
}  
DisplayMsg("WriteToFile SUCCESS ?? - see file.nativePath: " + nativePath);  
} // WriteToFile  
The only problem is that the file gets put deep down in the system c:/Users… folder which can be a real pain to acces. The solutoin is to create a linked directory (mklink) in a convenient place.  
Please consider this issue solved.

---

<div class="post-metadata">

**Author:** ![Dirk](https://avatars.discourse-cdn.com/v4/letter/d/87869e/32.png) [@Dirk](https://forums.creativeclouddeveloper.com/u/Dirk)\
**Post date:** [February 9, 2025, 10:29am UTC](https://forums.creativeclouddeveloper.com/t/indesign-file-system-writefile-works-from-an-idjs-script-not-from-a-plugin/9203/3 "2025-02-09T10:29:52Z")

</div>

Have you written your manifest permissions along those implied for UXPScript?

> **[Manifest for scripts and plugins](https://developer.adobe.com/indesign/uxp/resources/fundamentals/manifest/)**
>
> Explains how permission module works for scripts and plugins

Edit: The linked page differs from the preview, refer to the section “Permission module for Scripts”.
