代码之家  ›  专栏  ›  技术社区  ›  Latheesan

watchify错误-npm ERR!缺少脚本:监视

  •  0
  • Latheesan  · 技术社区  · 5 年前

    我想知道如何使用这个名为 simple-peer ,所以我设置了一个测试项目。它具有以下dir结构:

    enter image description here

    这是我的 文件:

    {
      "author": "Latheesan Kanesamoorthy",
      "name": "simple-peer-test",
      "version": "1.0.0",
      "description": "A simple video chat app using simple-peer using WebRTC.",
      "main": "main.js",
      "scripts": {
        "start": "nodemon ./src/server.js",
        "watch": "npx watchify ./src/main.js -o ./public/bundle.js"
      },
      "dependencies": {
        "express": "^4.17.1",
        "simple-peer": "^9.4.0",
        "socket.io": "^2.2.0"
      },
      "devDependencies": {
        "nodemon": "^1.19.1",
        "watchify": "^3.11.1"
      }
    }
    

    运行此命令时: npm run watch ,我收到以下错误:

    npm错误!缺少脚本:监视

    这是我的调试日志:

    0 info it worked if it ends with ok
    1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
    1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
    1 verbose cli   'run',
    1 verbose cli   'watch' ]
    2 info using npm@6.9.0
    3 info using node@v10.16.0
    4 verbose stack Error: missing script: watch
    4 verbose stack     at run (C:\Program Files\nodejs\node_modules\npm\lib\run-script.js:155:19)
    4 verbose stack     at C:\Program Files\nodejs\node_modules\npm\lib\run-script.js:63:5
    4 verbose stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:115:5
    4 verbose stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:418:5
    4 verbose stack     at checkBinReferences_ (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:373:45)
    4 verbose stack     at final (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:416:3)
    4 verbose stack     at then (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:160:5)
    4 verbose stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:364:12
    4 verbose stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\graceful-fs.js:90:16
    4 verbose stack     at FSReqWrap.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:53:3)
    5 verbose cwd C:\Users\Latheesan\Desktop\simple-peer-test
    6 verbose Windows_NT 10.0.17763
    7 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "watch"
    8 verbose node v10.16.0
    9 verbose npm  v6.9.0
    10 error missing script: watch
    11 verbose exit [ 1, true ]
    

    你知道这里出了什么问题吗?

    0 回复  |  直到 5 年前