I have this on top of my index.js
import express from 'express'
import favicon from 'serve-favicon'
import router from express.Router()
I kept getting
[nodemon] app crashed - waiting for file changes before starting...
[nodemon] restarting due to changes...
[nodemon] starting `babel-node ./index.js`
/Users/bheng/Desktop/express-app/node_modules/babel-core/lib/transformation/file/index.js:590
throw err;
^
SyntaxError: /Users/bheng/Desktop/express-app/index.js: Unexpected token (3:19)
1 | import express from 'express'
2 | import favicon from 'serve-favicon'
> 3 | import router from express.Router()
| ^
What is the correct syntax for that ? What did I do wrong ?
您已经导入了快递,因此访问Router
无需再导入。
const router = express.Router();
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.