Skip to content

ENOENT: no such file or directory capacitor.config.json #285

Description

@woutersteven

Describe the bug

Error, when Capacitor v5 (angular) project has capacitor.config.ts file (but not a JSON file). When running the Windows executable, or when running the command:

npx electron .\build\src\index.js

I get the error:

Error: ENOENT: no such file or directory, open 'C:\FOLDER\electron\build\src\capacitor.config.json"

This is after necessary changes were made to run everything as ESModules.

package.json

{
  "name": "name",
  "version": "1.0.0",
  "description": "An Amazing Capacitor App",
  "author": {
    "name": "",
    "email": "email@address.com"
  },
  "repository": {
    "type": "git",
    "url": ""
  },
  "type": "module",
  "license": "MIT",
  "engines": {
    "node": ">=16"
  },
  "exports": "./build/src/index.js",
  "scripts": {
    "build": "tsc",
    "electron:start-live": "node ./live-runner.cjs",
    "electron:start": "npm run build && electron --inspect=5858 ./",
    "electron:pack": "npm run build && electron-builder build --dir -c ./electron-builder.config.json",
    "electron:make": "npm run build && electron-builder build -c ./electron-builder.config.json -p always"
  },
  "dependencies": {
    "@capacitor-community/electron": "^5.0.1",
    "chokidar": "~3.6.0",
    "electron-is-dev": "~3.0.1",
    "electron-serve": "~2.0.0",
    "electron-unhandled": "~5.0.0",
    "electron-updater": "^6.2.1",
    "electron-window-state": "^5.0.3"
  },
  "devDependencies": {
    "electron": "^30.0.3",
    "electron-builder": "~24.13.3",
    "typescript": "^5.4.5"
  }
}

tsconfig.json

{
  "compileOnSave": true,
  "include": ["./src/**/*", "./capacitor.config.ts", "./capacitor.config.js"],
  "compilerOptions": {
    "outDir": "./build",
    "importHelpers": true,
    "target": "ES2017",
    "module": "Node16",
    "moduleResolution": "Node16",
    "esModuleInterop": true,
    "typeRoots": ["./node_modules/@types"],
    "allowJs": true,
    "rootDir": ".",
    "skipLibCheck": true,
  }
}

After running "electron:pack", i can see in the ./build folder that a capacitor.config.js file is present, but not the .json file.

I am guessing that the search for "capacitor.config.json" is hard-coded?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions