Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ubuntu Server 20.04: oputil.js gives 'flat is not a function' error #422

Closed
LilFonky opened this issue May 11, 2022 · 7 comments
Closed

Comments

@LilFonky
Copy link

Describe the Bug
Attempting to install using curl script, which appears to complete without issue. Unable to complete initial config due to ./oputil.js config new erroring out with

(node:319138) UnhandledPromiseRejectionWarning: TypeError: this.breakLines(...).flat is not a function

Will include full terminal output below

To Reproduce

Just run ./oputil.js config new after initial install. Tried npm rebuild with no effect.

Expected Behavior
Expected prompts associated with first run configuration.

Actual Behavior

analytic@origin:~/enigma-bbs$ ./oputil.js config new
(node:319138) UnhandledPromiseRejectionWarning: TypeError: this.breakLines(...).flat is not a function
    at ScreenManager.forceLineReturn (/home/analytic/enigma-bbs/node_modules/inquirer/lib/utils/screen-manager.js:172:56)
    at ScreenManager.render (/home/analytic/enigma-bbs/node_modules/inquirer/lib/utils/screen-manager.js:81:20)
    at ConfirmPrompt.render (/home/analytic/enigma-bbs/node_modules/inquirer/lib/prompts/confirm.js:70:17)
    at ConfirmPrompt._run (/home/analytic/enigma-bbs/node_modules/inquirer/lib/prompts/confirm.js:51:10)
    at Promise (/home/analytic/enigma-bbs/node_modules/inquirer/lib/prompts/base.js:61:12)
    at new Promise (<anonymous>)
    at ConfirmPrompt.run (/home/analytic/enigma-bbs/node_modules/inquirer/lib/prompts/base.js:60:12)
    at defer (/home/analytic/enigma-bbs/node_modules/inquirer/lib/ui/prompt.js:105:30)
    at Observable._subscribe (/home/analytic/enigma-bbs/node_modules/rxjs/dist/cjs/internal/observable/defer.js:8:31)
    at Observable._trySubscribe (/home/analytic/enigma-bbs/node_modules/rxjs/dist/cjs/internal/Observable.js:41:25)
(node:319138) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3)
(node:319138) [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.

Tried updating to latest version of nodejs and seem to have made matters worse:

./oputil.js config new
internal/modules/cjs/loader.js:818
  throw err;
  ^

Error: Cannot find module '/home/analytic/enigma-bbs/node_modules/sqlite3/lib/binding/node-v72-linux-x64/node_sqlite3.node'
Require stack:
- /home/analytic/enigma-bbs/node_modules/sqlite3/lib/sqlite3-binding.js
- /home/analytic/enigma-bbs/node_modules/sqlite3/lib/sqlite3.js
- /home/analytic/enigma-bbs/core/database.js
- /home/analytic/enigma-bbs/core/oputil/oputil_common.js
- /home/analytic/enigma-bbs/core/oputil/oputil_main.js
- /home/analytic/enigma-bbs/oputil.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)                       
    at Function.Module._load (internal/modules/cjs/loader.js:667:27)                                  
    at Module.require (internal/modules/cjs/loader.js:887:19)                                         
    at require (internal/modules/cjs/helpers.js:74:18)                                                
    at Object.<anonymous> (/home/analytic/enigma-bbs/node_modules/sqlite3/lib/sqlite3-binding.js:4:15)
    at Module._compile (internal/modules/cjs/loader.js:999:30)                                        
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)                         
    at Module.load (internal/modules/cjs/loader.js:863:32)                                            
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)                                  
    at Module.require (internal/modules/cjs/loader.js:887:19) {                                       
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/analytic/enigma-bbs/node_modules/sqlite3/lib/sqlite3-binding.js',                          
    '/home/analytic/enigma-bbs/node_modules/sqlite3/lib/sqlite3.js',                                  
    '/home/analytic/enigma-bbs/core/database.js',
    '/home/analytic/enigma-bbs/core/oputil/oputil_common.js',                                         
    '/home/analytic/enigma-bbs/core/oputil/oputil_main.js',                                           
    '/home/analytic/enigma-bbs/oputil.js'
  ]
}

Environment

  • I am using Node.js v12.x LTS or higher

  • npm install or yarn reports success

  • Actual Node.js version (node --version): 12.22.12

  • Operating system (uname -a on *nix systems): Linux origin 5.4.0-109-generic 0.0.7 alpha #123-Ubuntu SMP Fri Apr 8 09:10:54 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

  • Revision (git rev-parse --short HEAD): ac38ac9

@LilFonky LilFonky changed the title Ubuntu Server 20.04: oputil.js give 'flat is not a function' error Ubuntu Server 20.04: oputil.js gives 'flat is not a function' error May 11, 2022
@LilFonky
Copy link
Author

Re-ran npm rebuild and now it seems to be working. Will leave this thread up just in case someone else hits this snag...

@NuSkooler
Copy link
Owner

If you're using the latest off of master you should be at version 0.0.13-beta and install.sh will require Node.js 14+. I see you're at version 12 -- you will need to upgrade.

I'll get this issue template updated. Looks like it was missed.

@LilFonky
Copy link
Author

Thanks I will look for it.

Just FTR I am able to run the config script but not able to run main.js, but I assume this is to do with the Node version. If it's not working I will post terminal output once I get a newer version of Node.js sorted. Thanks for the heads-up!

@LilFonky
Copy link
Author

LilFonky commented May 11, 2022

OK upgraded to Node.js 16.15.0 and still unable to run ./main.js. Terminal says this:

analytic@origin:~/enigma-bbs$ ./main.js
node:internal/modules/cjs/loader:936
  throw err;
  ^

Error: Cannot find module '/home/analytic/enigma-bbs/node_modules/sqlite3/lib/binding/node-v93-linux-x64/node_sqlite3.node'
Require stack:
- /home/analytic/enigma-bbs/node_modules/sqlite3/lib/sqlite3-binding.js
- /home/analytic/enigma-bbs/node_modules/sqlite3/lib/sqlite3.js
- /home/analytic/enigma-bbs/core/database.js
- /home/analytic/enigma-bbs/core/bbs.js
- /home/analytic/enigma-bbs/main.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)                     
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)                                
    at Module.require (node:internal/modules/cjs/loader:1005:19)                                      
    at require (node:internal/modules/cjs/helpers:102:18)                                             
    at Object.<anonymous> (/home/analytic/enigma-bbs/node_modules/sqlite3/lib/sqlite3-binding.js:4:15)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)                                     
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)                       
    at Module.load (node:internal/modules/cjs/loader:981:32)                                          
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)                                
    at Module.require (node:internal/modules/cjs/loader:1005:19) {                                    
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/analytic/enigma-bbs/node_modules/sqlite3/lib/sqlite3-binding.js',                          
    '/home/analytic/enigma-bbs/node_modules/sqlite3/lib/sqlite3.js',                                  
    '/home/analytic/enigma-bbs/core/database.js',
    '/home/analytic/enigma-bbs/core/bbs.js',
    '/home/analytic/enigma-bbs/main.js'
  ]
}

If if do bash main.js I get:

analytic@origin:~/enigma-bbs$ bash main.js
main.js: line 3: /bin: Is a directory
main.js: line 4: use strict: command not found
main.js: line 6: /bin: Is a directory
main.js: line 7: ENiGMA½: command not found
main.js: line 12: unexpected EOF while looking for matching `''
main.js: line 13: syntax error: unexpected end of file

Any insight will be much appreciated!

@NuSkooler
Copy link
Owner

After updating Node, you need to run npm install or (yarn, if you used that) again. To be extra safe, delete the node_modules directory first.

main.js isn't a Bash script, so you wont' be able to do that. It's executable though, so once you do the above to fix the modules, you can just ./main.js or node main.js

@LilFonky
Copy link
Author

Just started it up successfully. Thanks for seeing me over the finish line!

@NuSkooler
Copy link
Owner

@LilFonky Awesome, I'm glad it's working for you! Enjoy!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants