Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

218
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda