javascript - 如何解决 npm start 上的这个节点 js 错误?
问题描述
使用 mac book pro 执行 npm start 后出现以下错误
错误片段
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
以下是我的 package.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 index.js 的脚本启动,但每次我执行 npm start 时,我都会收到上述错误,搜索有关如何解决它的线索,但在 stackover 流或其他来源上没有结果。
解决方案
function
我想你之前忘记了关键字remove(item)
。
const async function remove(item) {
// Your function code here
}
或使用箭头功能:
cons remove = async (item) => {
// Your function code here
}
推荐阅读
- reactjs - React / Redux:多次调用 mapStateToProps()
- asp.net-mvc - 从 Angular 服务中的 .NET appSettings.json 文件中读取环境变量?
- groovy - splitCsv 然后在 Nextflow 中映射一个 URL 列表
- java - Spring @RestController 响应已经提交
- c# - 从给定的日期数组中获取下一个即将到来的日子,比较今天的 C#
- angular - 如何获取复选框列表值并以另一种形式显示(角度4)
- python - 通过仅考虑百分位范围内的值来估计 DataFrameGroupBy 的平均值
- c# - Linq where 表达式作为要添加的值
- sql - SQL 命名列
- javascript - PDF JS:在 DOCX 到 PDF 转换期间自动将 JavaScript 添加到 PDF