Sails: TypeError: Cannot read property 'readJson' of undefined

Created on 17 Jun 2019  路  11Comments  路  Source: balderdashy/sails

Node version: v10.15.0
Sails version _(sails)_: 1.2.2


I created a new app with --no-front-end as I only want REST API functionality.
When trying to use sails lift

I get the following error:
TypeError: Cannot read property 'readJson' of undefined

This is the traceback:
at Object.module.exports.bootstrap (\config\bootstrap.js:40:55) at \node_modules\sails\lib\app\private\bootstrap.js:73:34 at Sails.runBootstrap (\node_modules\sails\lib\app\private\bootstrap.js:97:5) at Sails.wrapper [as runBootstrap] (\node_modules\@sailshq\lodash\lib\index.js:3275:19) at Sails.initialize (\node_modules\sails\lib\app\private\initialize.js:67:9) at Sails.wrapper [as initialize] (\node_modules\@sailshq\lodash\lib\index.js:3275:19) at \node_modules\sails\lib\app\lift.js:63:13 at \node_modules\sails\node_modules\async\dist\async.js:3853:24 at replenish (\node_modules\sails\node_modules\async\dist\async.js:946:17) at iterateeCallback (\node_modules\sails\node_modules\async\dist\async.js:931:17) at \node_modules\sails\node_modules\async\dist\async.js:906:16 at \node_modules\sails\node_modules\async\dist\async.js:3858:13 at \node_modules\sails\lib\app\load.js:279:13 at \node_modules\sails\node_modules\async\dist\async.js:421:16 at processQueue (\node_modules\sails\node_modules\async\dist\async.js:1565:20) at taskComplete (\node_modules\sails\node_modules\async\dist\async.js:1588:9)

I haven't done anything else since creating new project.

bug generators inconsistency pr welcome proposal

Most helpful comment

@abhishekkhaware @raqem I commented over in gitter here https://gitter.im/balderdashy/sails?at=5d428d1a3e05746cc8a2246a

Looks like --no-front-end & choosing the "Web App" starter doesn't pull in sails-hook-organics but the generated config/bootstrap.js tries to use sails.helpers.fs.readJson 馃し鈥嶁檪

All 11 comments

@KlemenS189 Thanks for posting! We'll take a look as soon as possible.

In the mean time, there are a few ways you can help speed things along:

  • look for a workaround. _(Even if it's just temporary, sharing your solution can save someone else a lot of time and effort.)_
  • tell us why this issue is important to you and your team. What are you trying to accomplish? _(Submissions with a little bit of human context tend to be easier to understand and faster to resolve.)_
  • make sure you've provided clear instructions on how to reproduce the bug from a clean install.
  • double-check that you've provided all of the requested version and dependency information. _(Some of this info might seem irrelevant at first, like which database adapter you're using, but we ask that you include it anyway. Oftentimes an issue is caused by a confluence of unexpected factors, and it can save everybody a ton of time to know all the details up front.)_
  • read the code of conduct.
  • if appropriate, ask your business to sponsor your issue. _(Open source is our passion, and our core maintainers volunteer many of their nights and weekends working on Sails. But you only get so many nights and weekends in life, and stuff gets done a lot faster when you can work on it during normal daylight hours.)_
  • let us know if you are using a 3rd party plugin; whether that's a database adapter, a non-standard view engine, or any other dependency maintained by someone other than our core team. _(Besides the name of the 3rd party package, it helps to include the exact version you're using. If you're unsure, check out this list of all the core packages we maintain.)_

Please remember: never post in a public forum if you believe you've found a genuine security vulnerability. Instead, disclose it responsibly.

For help with questions about Sails, click here.

Hi @KlemenS189 I was not able to reproduce this issue. Could you try to $rm -rf node_modules/ package-lock.json .npmrc and then do a fresh $npm install
If that does not work can you please try to generate a new sails project again and see if you come up with the same issue?
sails new your-app-name --no-frontend

Hi @raqem I am also facing same issue. I also tried $rm -rf node_modules/ package-lock.json .npmrc and then do a fresh $npm install but it didn't worked at all.

I have also tried to create new project with older version (v 1.2.1) but facing same issue.

Node version: v12.7.0
Sails version (sails): 1.2.3
OS Windows 10 and Ubuntu 18.04

Whenever I try to create a new project,
sails new demo-api --no-front-end
then in the project directory, I tried to run sails lift it is throwing errors,

error: Bootstrap encountered an error: (see below)
error:
error: TypeError: Cannot read property 'readJson' of undefined
at Object.module.exports.bootstrap (/var/www/html/demo-api/config/bootstrap.js:40:55)
at /var/www/html/demo-api/node_modules/sails/lib/app/private/bootstrap.js:73:34

@abhishekkhaware @raqem I commented over in gitter here https://gitter.im/balderdashy/sails?at=5d428d1a3e05746cc8a2246a

Looks like --no-front-end & choosing the "Web App" starter doesn't pull in sails-hook-organics but the generated config/bootstrap.js tries to use sails.helpers.fs.readJson 馃し鈥嶁檪

@nahanil Yes, you are right. I installed the sails-hook-organics package with npm i --save sails-hook-organics It is working fine now.

I think, this package should be included by default or at-least mentioned in documentation and readme file.

CC @raqem

@KlemenS189 @nahanil @abhishekkhaware

Hi, all!

I was able to replicate this error by creating a new app with sails new test-app-name --no-front-end, selecting 1. Web App when prompted, and then running sails lift.

When I installed sails-hook-organics as described by @abhishekkhaware, I was able to lift without any issues.

We'll have to give some thought to how we want to resolve this issue. Thanks so much for bringing it to our attention!

The Sails team has converged to discuss this issue! Since the web app is so frontend-heavy, we're probably going to resolve this problem by displaying an error if you try to select the Web App option when creating a new no-front-end Sails app.

I think, there should be no selection option, when we create new with no-front-end flag. It should always create empty project.

@abhishekkhaware鈥攇ood thought! I'll take it up with the team.

I think, there should be no selection option, when we create new with no-front-end flag. It should always create empty project.

I agree. I was a little perturbed when I saw this. All together I love Sails

displaying an error if you try to select the Web App option when creating a new no-front-end Sails app

This is a good plan -- I'm ok with either an error or not showing the prompt (if --no-front-end, act like --traditional is also set). Will be a PR to sails-generate.

Was this page helpful?
0 / 5 - 0 ratings