Finley Sayer
Finley Sayer

Reputation: 11

Using node-webkit "npm start" is not calling the script from my package.json manifest file

When executing npm start in the terminal I am greeted with this error message:

PS C:\Users\finsa\OneDrive\Documents\UNI\Web Development\NS_Music_App> npm start

> [email protected] start
> nw src/

(node:6380) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
Error: spawn C:\Users\finsa\OneDrive`your text`\Documents\UNI\Web Development\NS_Music_App\nwjs-sdk-v0.86.0-win-x64\nw.exe ENOENT
    at ChildProcess._handle.onexit (node:internal/child_process:286:19)
    at onErrorNT (node:internal/child_process:484:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'spawn C:\\Users\\finsa\\OneDrive\\Documents\\UNI\\Web Development\\NS_Music_App\\nwjs-sdk-v0.86.0-win-x64\\nw.exe',
  path: 'C:\\Users\\finsa\\OneDrive\\Documents\\UNI\\Web Development\\NS_Music_App\\nwjs-sdk-v0.86.0-win-x64\\nw.exe',
  spawnargs: [ 'src/' ]
}
node:internal/process/esm_loader:34
      internalBinding('errors').triggerUncaughtException(
                                ^

Error: spawn C:\Users\finsa\OneDrive\Documents\UNI\Web Development\NS_Music_App\nwjs-sdk-v0.86.0-win-x64\nw.exe ENOENT
    at ChildProcess._handle.onexit (node:internal/child_process:286:19)
    at onErrorNT (node:internal/child_process:484:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'spawn C:\\Users\\finsa\\OneDrive\\Documents\\UNI\\Web Development\\NS_Music_App\\nwjs-sdk-v0.86.0-win-x64\\nw.exe',
  path: 'C:\\Users\\finsa\\OneDrive\\Documents\\UNI\\Web Development\\NS_Music_App\\nwjs-sdk-v0.86.0-win-x64\\nw.exe',
  spawnargs: [ 'src/' ]
}

Node.js v20.12.2

Here is how my project is formatted

./package.json:

{
    "name": "ns_music_app",
    "version": "1.0.0",
    "description": "",
    "main": "index.js",
    "scripts": {
        "start": "nw src/",
        "prod": "nwbuild --platforms win32,win64,osx64,linux32,linux64 --buildDir dist/ src/"
    },
    "keywords": [],
    "author": "",
    "license": "ISC",
    "devDependencies": {
        "nw": "^0.86.0-sdk",
        "nw-builder": "^4.7.1"
    }
}

./src/package.json:

{
    "name": "src",
    "version": "1.0.0",
    "description": "",
    "main": "views/main.html",
    "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1"
    },
    "window": {
        "title": "NS-Music-App"
    },
    "keywords": [],
    "author": "",
    "license": "ISC"
}

I have tried uninstalling and reinstalling Node.js, node-webkit, and reinitialising package.json files. I have also ensured that ignore-script is configured to false.

I suspect that it has something tp do with the path used to fetch nw.exe as in the error message it returns Web Development\\NS_Music_App\\nwjs-sdk-v0.86.0-win-x64\\nw.exe when the actual file path should be Web Development\\NS_Music_App\\node_modules\\nw\\nwjs-sdk-v0.86.0-win-x64\\nw.exe. But I'm not sure how to fix this.

Upvotes: 0

Views: 63

Answers (2)

Kavin Mercer
Kavin Mercer

Reputation: 11

I had a similar issue, a way to get it to work was if i downloaded the source files from the NW.js site for the same version i installed from npm, and replaced the zipped folder in the projects node_modules/nw with an unzipped file from the downloaded source files. Then running npm start worked. Also verify if you should be running "start": "nw src/" or "start": "nw ."

Upvotes: 0

The Jared Wilcurt
The Jared Wilcurt

Reputation: 349

I think you just need to change "start": "nw src/", to "start": "nw ./src",.

I made an example repo:

Upvotes: 0

Related Questions