简体   繁体   中英

nodemon app crashed - waiting for file changes before starting?

PS D:\PROGRAMMING\2077\SHOPIT> npm run dev > shopit@1.0.0 dev D:\PROGRAMMING\2077\SHOPIT > SET NODE_ENV=DEVELOPMENT& nodemon backend/server > [nodemon] 2.0.7 > [nodemon] to restart at any time, enter `rs` > [nodemon] watching path(s): *.* > [nodemon] watching extensions: js,mjs,json > [nodemon] starting `node backend/server.js` > D:\PROGRAMMING\2077\SHOPIT\backend\routes\product.js:6 > router.routes('/products').get(getProducts); ^ > TypeError: router.routes is not a function > at Object.<anonymous> (D:\PROGRAMMING\2077\SHOPIT\backend\routes\product.js:6:8) > at Module._compile (internal/modules/cjs/loader.js:1063:30) > at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10) > at Module.load (internal/modules/cjs/loader.js:928:32) > at Function.Module._load (internal/modules/cjs/loader.js:769:14) > at Module.require (internal/modules/cjs/loader.js:952:19) at require >(internal/modules/cjs/helpers.js:88:18) > at Object.<anonymous> (D:\PROGRAMMING\2077\SHOPIT\backend\app.js:8:18) > at Module._compile (internal/modules/cjs/loader.js:1063:30) > at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10) > [nodemon] app crashed - waiting for file changes before starting...

It says why in the error, you are trying to call something, maybe an array/object etc. instead of calling a function.

router.routes = ['/','/api','/ping'];
router.routes(); // ERROR

Check the type of router.routes

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM