Skip to content

Error writing within nodejs-assets or nodejs-project dir iOS #3

@scriptjs

Description

@scriptjs

I created a var folder locally in node assets and added this to may main.js within my nodejs-project. This puts the var folder at the same level as the nodejs-project

var fs = require('fs');
var varDir = path.join(__dirname, '..', 'var')
fs.writeFile(varDir, "Test write", function(err) {
    if(err) return console.log(err);
    console.log("The file was written");
})

I receive an errorno: -1, 'EPERM: operation not permitted' error when attempting to write to it. I also tried writing to nodejs-project with the same effect. I'd like to add files into the node project folder. For stashing files, the general director in iOS is

/var/mobile/Applications/<myappid>/Documents 

but attempting a write here does not work either:

var appId = (__dirname).split(path.sep)[6]
var docsDir = path.join(path.sep,'var', 'mobile', 'Applications', appId, 'Documents')
console.log(`docsDir: ${docsDir}`)

fs.writeFile(path.join(docsDir, 'test.txt'), "Test write", function(err) {
    if(err) return console.log(err);
    console.log("The file was written");
});

I receive the following error:

{ [Error: ENOENT: no such file or directory, open '/var/mobile/Applications/<myappid>/Documents/test.txt']
  message: 'ENOENT: no such file or directory, open \'/var/mobile/Applications/<myappid>/Documents/test.txt\'',
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '/var/mobile/Applications/<myappid>/Documents/test.txt' }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions