dawson-org / dawson-cli

A serverless web framework for Node.js on AWS (CloudFormation, CloudFront, API Gateway, Lambda)
https://dawson.sh
GNU General Public License v3.0
712 stars 25 forks source link

package.json not found error is misleading #158

Closed dmfenton closed 7 years ago

dmfenton commented 7 years ago
➜  koop-provider-craigslist git:(master) ✗ dawson dev

   Execution Error
   Cannot find package.json

   Possible cause
   There is no package.json file in the current directory

   You are running this command from '/Users/foobar/repos/koop-provider-craigslist' which does not
   contain a package.json file as required by dawson.

   Possible solution
   * check if the file exists by running 'stat /Users/foobar/repos/koop-provider-craigslist/package.json'
   * run dawson from the correct folder
   * check file permissions on package.json

   If you believe this is not an expected behaviour or that this error message should be improved, open an issue: https://github.com/dawson-org/dawson-cli/issues
➜  koop-provider-craigslist git:(master) ✗ stat /Users/foobar/repos/koop-provider-craigslist/package.json
16777220 167870324 -rwxrwxrwx 1 dani7825 (1968095660 0 1005 "Mar 25 19:14:26 2017" "Mar 25 19:12:55 2017" "Mar 25 19:14:17 2017" "Mar 25 19:12:55 2017" 4096 8 0 /Users/foobar/repos/koop-provider-craigslist/package.json

Package.json exists but there is a syntax error

https://github.com/dmfenton/koop-provider-craigslist/tree/dawson

alexcasalboni commented 7 years ago

Hi @dmfenton,

if you check your file on Github you can already spot the syntax error :)

@lusentis I guess the error message could be improved?

dmfenton commented 7 years ago

Thanks! I updated this issue to reflect the confusing error message.

dmfenton commented 7 years ago

I fixed the syntax error but now I get this

dawson dev
   Execution Error
   dawson configuration error

   Possible cause
   Path specified by 'assetsDir' does not exist.

   Possible solution
   Directory does not exist: '/Users/foobar/repos/koop-provider-craigslist/assets',
   either create this directory, set the correct value for the 'assetsDir' property
   in package.json, or set 'assetsDir' to false if you're not using static assets.
alexcasalboni commented 7 years ago

@dmfenton quoting the documentation: "Specify false to skip deploying assets", and I assume that's what you are trying to do.

Looking at the code, it seems like such error message would never show up if assetsDir is actually false.

In case you are not specifying false, then could you share your current configuration? (your package.json doesn't seem to be up to date?)

dmfenton commented 7 years ago

assetsDir is false and this is showing up. I just pushed up the code again

alexcasalboni commented 7 years ago

@dmfenton I think the problem is that assetsDir should be defined inside a dawson property in your package.json file, as documented here.

dmfenton commented 7 years ago

yep, that did it. thank you. I must say I'm not sure I understood what Dawson Dev was going to do. I thought it was going to start a server locally, but looks like its actually pushing things to AWS?

alexcasalboni commented 7 years ago

You are welcome.

Yes, Dawson will run a local server if you execute dawson dev. The local development documentation is not complete yet, but it will be very soon :)

lusentis commented 7 years ago

Thanks to everyone,


I thought it was going to start a server locally, but looks like its actually pushing things to AWS?

dev server docs are coming asap, in the meantime (any suggestion / PR to make this more clear will be really appreciated):

dawson dev:

@dmfenton Hope this clarifies your expectations, if not, please let us know!

Thanks for your feedback,

lusentis commented 7 years ago

@dmfenton It would be awesome if you could start a PR to fix this message. Starting from this line: https://github.com/dawson-org/dawson-cli/blob/master/src/config.js#L354 I'd do an if to check if the error is instanceof SyntaxError and display the appropriate message (see https://github.com/dawson-org/dawson-cli/blob/master/src/libs/language-javascript-latest/describeApi.js#L50 for a similar implementation).

dmfenton commented 7 years ago

I appreciate your help on this, but I've decided to go with Claudia.js for now. Will check back in with this project sometime in the future!

stale[bot] commented 7 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

lusentis commented 7 years ago

fixed in 828381c9efc75a6b01cfcd132daaf34d76ff09af, will be released in v0.28 soon.

lusentis commented 7 years ago

additionally, 56156cab59b8581a08220c412c1a007a70735043 fixes that assetsDir behaviour and allows deploying without having to specify assetsDir = false.