balderdashy / sails

Realtime MVC Framework for Node.js
https://sailsjs.com
MIT License
22.86k stars 1.95k forks source link

TypeError: Cannot read property 'readJson' of undefined #6789

Open KlemenS189 opened 5 years ago

KlemenS189 commented 5 years ago

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.

sailsbot commented 5 years ago

@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:

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.

raqem commented 5 years ago

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

abhishekkhaware commented 5 years ago

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

nahanil commented 5 years ago

@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 🤷‍♂

abhishekkhaware commented 5 years ago

@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

whichking commented 5 years ago

@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!

whichking commented 5 years ago

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.

abhishekkhaware commented 5 years ago

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

whichking commented 5 years ago

@abhishekkhaware—good thought! I'll take it up with the team.

DominusKelvin commented 4 years ago

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

mikermcneil commented 4 years ago

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.