使用node-webkit“npm start”不会从我的package.json清单文件中调用脚本

问题描述 投票:0回答:1

在终端中执行

npm start
时,我收到以下错误消息:

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"
}

我尝试卸载并重新安装 Node.js、node-webkit,并重新初始化

package.json
文件。我还确保忽略脚本配置为 false。

我怀疑它与用于获取

nw.exe
的路径有一些关系,因为当实际文件路径应该是
Web Development\\NS_Music_App\\nwjs-sdk-v0.86.0-win-x64\\nw.ex
时,它返回
Web Development\\NS_Music_App\\node_modules\\nw\\nwjs-sdk-v0.86.0-win-x64\\nw.exe
e 的错误消息。但我不知道如何解决这个问题。

javascript node.js npm node-webkit
1个回答
0
投票

我认为你只需要将

"start": "nw src/",
更改为
"start": "nw ./src",

我做了一个示例仓库:

© www.soinside.com 2019 - 2024. All rights reserved.