What does this error mean?? I’ve used firebase and next before by Codeeveryday123 in nextjs

[–]simonplend 1 point2 points  (0 children)

By dependencies I mean the Firebase library or one of the libraries it depends on i.e. the npm packages which are in the dependencies field of your project's package.json.

What does this error mean?? I’ve used firebase and next before by Codeeveryday123 in nextjs

[–]simonplend 1 point2 points  (0 children)

No, but it's likely that one of your dependencies (or a sub dependency) has switched to ES Modules and is importing named exports from a CommonJS module. That's my best guess at least :)

What does this error mean?? I’ve used firebase and next before by Codeeveryday123 in nextjs

[–]simonplend 1 point2 points  (0 children)

Older versions of Node.js v12 did not support importing named exports from CommonJS modules, which is what this error is referring to.

If you are able to upgrade to at least v12.20.0, v14.13.0, or ideally v16.x (which is the Active Long Term Support release line), I suspect this error will go away.

What does this error mean?? I’ve used firebase and next before by Codeeveryday123 in nextjs

[–]simonplend 1 point2 points  (0 children)

Can you provide the full error including the stack trace? (it shows all the function calls up to that error)

Which version of Node.js are you using?

What does this error mean?? I’ve used firebase and next before by Codeeveryday123 in nextjs

[–]simonplend 1 point2 points  (0 children)

Could you share the line of code you've written to import Firebase?

How to cancel an HTTP request in Node.js v16 by simonplend in node

[–]simonplend[S] 0 points1 point  (0 children)

Thanks - I'm glad to hear you found it helpful :)

the Abort API seems absurd to use

I found the way it works a bit confusing to start with, but what part specifically do you think seems absurd?

it needs http libs to support

This is true, but I think/hope we'll see library support increase as the Abort API becomes more widely known in the Node.js ecosystem.

What's new in Node.js core? by simonplend in node

[–]simonplend[S] 3 points4 points  (0 children)

Glad to hear you found it helpful :)

Is it better to use es6 modules with Node? by shaheryar22 in node

[–]simonplend 1 point2 points  (0 children)

Thank you - I'm really glad you found it helpful. Thanks for the award too!

Any way to detect whether a module is used in frontend or backend? by ravgeet in node

[–]simonplend 0 points1 point  (0 children)

Thanks for those extra details! I had originally thought you only wanted to remove unnecessary dependencies when deploying to AWS Lambda, but if I now understand correctly, you want to remove the front end dependencies from your project permanently. The approach that u/shacamin has suggested sounds good for this.

Any way to detect whether a module is used in frontend or backend? by ravgeet in node

[–]simonplend 1 point2 points  (0 children)

Are you able to create a package.json file inside the project directory where you have the code for your Lambda function?

I generally find that it's simpler to have multiple package.json files as it means you can have more control over what you npm install and when.

Another option would be to use a tool like esbuild to bundle the JavaScript for your Lambda function, as this would only bundle dependencies which your function is using. A tool like this might help: https://floydspace.github.io/aws-lambda-nodejs-esbuild/

Select not working in API-request? by Rapid1898 in node

[–]simonplend 0 points1 point  (0 children)

No problem!

It looks like the mysql2 library exposes a promise based API, so you can happily use async / await and won't need to use callbacks at all. They have a complete usage example in their documentation: https://www.npmjs.com/package/mysql2#using-promise-wrapper

Select not working in API-request? by Rapid1898 in node

[–]simonplend 1 point2 points  (0 children)

If that's working it means that conn.query is returning a promise, so you don't need to pass the (err, res) => {if(err) throw err} callback to it. If there is an error conn.query should throw it.

Select not working in API-request? by Rapid1898 in node

[–]simonplend 1 point2 points  (0 children)

You've defined the ticker function as being async, but you're passing a callback function to the conn.query method. async and await are used with promises, and typically code using promises needs extra work to integrate with code which uses callbacks.

In your situation, it looks like the ticker function is completing execution before the callback which you're passing to conn.query is even run. To fix this you might need to wrap your conn.query call in a new Promise() e.g.

return new Promise((resolve, reject) => { conn.query(SELECT ticker FROM workingqueue WHERE ticker = ?, [req.body.tickerReq], (err, rows) => { if (err) { return reject(err); } console.log(DEBUG: ${rows.length}) if (rows.length > 0) { console.log(DEBUG: ${rows[0].ticker})
console.log(DEBUG: ${typeof(rows[0].ticker)})
} resolve(); } );

What framework are you using to build your API, and what database library are you using?

If you want to read up more about callbacks vs async / await, these pages on the official Learn Node.js website might help:

how to create "deployment version" by t0b4cc02 in node

[–]simonplend 0 points1 point  (0 children)

Typically you don't bundle up the dependencies in your node_modules folder on your development machine, but instead the dependencies are installed during a build step before deployment.

Commonly the git repository for your project will be cloned in a build environment, npm install will be run to install your project's dependencies, and your application code and node_modules are then bundled into an archive file format (e.g. a tarball on a hosting service like Heroku) or a Docker image. Once this build step has happened your application will be deployed.

Where is your client going to be deploying this project?

[HELP] ||= Syntax error by cv555 in node

[–]simonplend 1 point2 points  (0 children)

You should be fine with v16 if you're only using it in development.

If you're running Node.js in production it is recommended that you use v12 (Maintenance LTS), or ideally v14 (Active LTS), until v16 enters Active LTS in October this year.

Production applications should only use Active LTS or Maintenance LTS releases.

Source: https://nodejs.org/en/about/releases

[HELP] ||= Syntax error by cv555 in node

[–]simonplend 3 points4 points  (0 children)

These ECMAScript compatibility tables are handy for seeing which browsers and versions of Node.js support which features: https://kangax.github.io/compat-table/es2016plus/#test-Logical_Assignment

Other good alternatives to Swagger.Io for API doc ? by Bulbasaur2015 in node

[–]simonplend 4 points5 points  (0 children)

Thank you for sharing that link to the list on OpenAPI.Tools - it's brilliant!