как решить эту ошибку node js при запуске npm? - PullRequest
0 голосов
/ 07 апреля 2020

Я получаю следующую ошибку после выполнения npm start Using ma c book pro

Фрагмент ошибки

dbrax: bot apple $ npm start

> bot@1.0.0 start /Users/apple/Desktop/saas/bot
> nodemon index.js

/Users/apple/Desktop/saas/bot/node_modules/chokidar/index.js:151
  async remove(item) {
        ^^^^^^
SyntaxError: Unexpected identifier
    at Object.exports.runInThisContext (vm.js:76:16)
    at Module._compile (module.js:542:28)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/apple/Desktop/saas/bot/node_modules/nodemon/lib/monitor/watch.js:6:16)
    at Module._compile (module.js:570:32)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! bot@1.0.0 start: `nodemon index.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the bot@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/apple/.npm/_logs/2020-04-07T06_46_27_297Z-debug.log

Ниже приведен мой пакет. json

  {
      "name": "bot",
      "version": "1.0.0",
      "description": "",
      "main": "index.js",
      "scripts": {
        "start": "nodemon index.js"
      },
      "author": "",
      "license": "ISC",
      "dependencies": {
        "express": "^4.17.1",
        "nodemon": "^2.0.2"
      }
    }

Пакет json выше имеет запуск сценария, который выполняет индекс nodemon. js, но каждый раз, когда я выполняю npm запуск, я получаю вышеуказанный поиск ошибок для подсказок о том, как его решить, но не приводит к потоку стека и другим источникам.

1 Ответ

1 голос
/ 08 апреля 2020

Полагаю, вы забыли ключевое слово function до remove(item).

const async function remove(item) {
  // Your function code here
}

или использовали функцию стрелки:

cons remove = async (item) => {
  // Your function code here
}
...