Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

225
Views
File permission error when try to create files on mac os

I created a test app on the Apple pc with Mac OS Monterey v12.0.1 in order to test the file and folder created.

However, when the file creation script runs with the "node-main": "./index.js" reference in the manifest file, it can not create files and gives the following permission error.

Error: Uncaught Error: EROFS: read-only file system, open './newfile.txt'

Steps followed:

Created the following files:

index.html
index.js
package.json

in the following location: nwjs-sdk-v0.49.1-osx-x64/nwjs.app/Contents/Resources/app.nw

index.js file contents are as follows:

var fs = require('fs');
const file_name = './new-file.txt';
fs.writeFile(file_name, 'Learn NWJS', function (err) {
  if (err) throw err;
  console.log('File is created successfully.');
});

package.json file contents are as follows:

{
  "name": "test-app",
  "node-main": "./index.js",
  "main": "./index.html"
}

Can anyone please help me to overcome this problem, please?

Env info:

  1. OS: Mac OS Monterey v12.0.1
  2. Local installed node: v14.18.1
  3. NWJS: v0.49.1-sdk (downloaded zip file and extracted)

NOTE: I have given permission to the NWJS app itself and also to the app.nw folder 777 in order to see the result but the result is zero.

Thank you.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I'm not sure the issue you are having (presume environment related). But another approach you can take that I've never had issues with is to npm install NW.js.

{
  "main": "index.html",
  "node-main": "index.js",
  "name": "example",
  "scripts": {
    "start": "nw ."
  },
  "devDependencies": {
    "nw": "0.49.1-sdk"
  }
}

If you already have Node installed, I would recommend uninstalling it and using nvm (Node Version Manager) to allow you to easily switch between Node versions. NW.js comes with Node built in, so it usually works best to have the same version of Node globally installed. So being able to easily switch versions is useful.

  • https://github.com/nvm-sh/nvm#installing-and-updating

NW.js 0.49.1 shipped with Node 14.13.1, so that's the version you want to globally install.

  1. Update your package.json to the one above, put it in an empty folder with just the index.html and index.js files next to it on your desktop.
  2. Install nvm
  3. Run nvm install 14.13.1
  4. Check your Node version matches with node -v
  5. Check that you have npm with npm -v (should come with Node)
  6. Run npm install && npm start from the folder with your package.json

That will download NW.js to a node_modules folder for you and run it. Any time you want to run it again you just need npm start.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!