fastify / fastify-example-twitter

Fastify example - clone twitter
MIT License
272 stars 48 forks source link

how to run this example ? #18

Closed samsom closed 6 years ago

samsom commented 6 years ago

C:\code\fastify\fastify-example-twitter\frontend>npm build npm WARN build npm build called with no arguments. Did you mean to npm run-sc ript build?

samsom commented 6 years ago

in another terminal:

server@1.0.0 start C:\code\fastify\fastify-example-twitter fastify index.js "--log-level" "trace" "--port" "3001"

AsyncFunction assert.js:212 assert.ifError = function ifError(err) { if (err) throw err; }; ^

Error: ENOENT: no such file or directory, stat 'C:\code\fastify\fastify-example- twitter\frontend\build' at fs.statSync (fs.js:968:11) at checkPath (C:\code\fastify\fastify-example-twitter\node_modules\fastify-s tatic\index.js:91:16) at checkPathsForErrors (C:\code\fastify\fastify-example-twitter\node_modules \fastify-static\index.js:76:13) at fastifyStatic (C:\code\fastify\fastify-example-twitter\node_modules\fasti fy-static\index.js:15:17) at Plugin.exec (C:\code\fastify\fastify-example-twitter\node_modules\avvio\p lugin.js:33:17) at Boot.loadPlugin (C:\code\fastify\fastify-example-twitter\node_modules\avv io\plugin.js:114:10) at Task.release (C:\code\fastify\fastify-example-twitter\node_modules\fastq\ queue.js:127:16) at worked (C:\code\fastify\fastify-example-twitter\node_modules\fastq\queue. js:169:10) at toLoad.finish (C:\code\fastify\fastify-example-twitter\node_modules\avvio \plugin.js:117:7) at done (C:\code\fastify\fastify-example-twitter\node_modules\avvio\plugin.j s:74:7) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! server@1.0.0 start: fastify index.js "--log-level" "trace" "--port" "3 001" npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the server@1.0.0 start script. npm ERR! This is probably not a problem with npm. There is likely additional log ging output above.

npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\samsom\AppData\Roaming\npm-cache_logs\2018-01-06T05_40_47 _161Z-debug.log

allevo commented 6 years ago

Hi! thanks for trying this example!!

which nodejs and npm version are you using?

Could you try to use node8 with npm5?

samsom commented 6 years ago

i use nodejs9. I will try node8. thanks u for your feedback.

allevo commented 6 years ago

@samsom The readme was wrong. I've created a PR to update it and I have already merged it into master

Try npm run build as the output suggests

samsom commented 6 years ago

Thanks a lot!

samsom commented 6 years ago

@allevo I love fastify and its style, I want to use it to develop my project. but I am newbie ,the best way for the fastify' Fans like me is learning by example project . so please help us to improve Readme.md。 cause when I use nodej8 and npm5 to run the code ,still have following err: ~/fastjs/fastify-example-twitter$ npm start -- --log-level trace --port 3001

server@1.0.0 start /home/test/fastjs/fastify-example-twitter fastify index.js "--log-level" "trace" "--port" "3001"

AsyncFunction (node:22202) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): MongoError: unknown option to collMod: validator (node:22202) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. Server listening on http://localhost:3001 events.js:183 throw er; // Unhandled 'error' event ^

Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED 127.0.0.1:6379 at Object._errnoException (util.js:1022:11) at _exceptionWithHostPort (util.js:1044:20) at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1182:14) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! server@1.0.0 start: fastify index.js "--log-level" "trace" "--port" "3001" npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the server@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! /home/test/.npm/_logs/2018-01-07T03_47_54_996Z-debug.log

allevo commented 6 years ago

Hi! this example works with mongodb and redis. The error message shows that the redis library tries to connect to 127.0.0.1:6379 but at that port no redis server is listening.

So, a possible solution is to install mongodb and redis database on you local machine. Another solution (better) is to set up docker on your local machine and use it to run mongodb and redis on localhost.

docker run --rm -d -p 6379:6379 redis
docker run --rm -d -p 27017:27017 mongo

Anyway thank you for trying this example. If the README is not clear is a problem/bug. So any problem is welcomed! I'll update the README asap

samsom commented 6 years ago

work. thanks allevo . I will write done my whole story about how to run this example tomorrow .

allevo commented 6 years ago

Thank you a lot!

I'm happy the example works well on your machine too!!!

I'll update the README asap

If you are in trouble please open another issue!