Skip to content

Unable to get pg module to work #50921

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

Closed
1 task done
lucgagan opened this issue Jun 7, 2023 · 5 comments
Closed
1 task done

Unable to get pg module to work #50921

lucgagan opened this issue Jun 7, 2023 · 5 comments
Labels
bug Issue was opened via the bug report template. locked

Comments

@lucgagan
Copy link
Contributor

lucgagan commented Jun 7, 2023

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
      Platform: darwin
      Arch: arm64
      Version: Darwin Kernel Version 22.3.0: Mon Jan 30 20:38:37 PST 2023; root:xnu-8792.81.3~2/RELEASE_ARM64_T6000
    Binaries:
      Node: 19.9.0
      npm: 9.6.3
      Yarn: N/A
      pnpm: 8.5.1
    Relevant packages:
      next: 13.4.5-canary.6
      eslint-config-next: 13.4.4
      react: 18.2.0
      react-dom: 18.2.0
      typescript: 5.1.3

Which area(s) of Next.js are affected? (leave empty if unsure)

App directory (appDir: true)

Link to the code that reproduces this issue or a replay of the bug

N/A

To Reproduce

N/A

Describe the Bug

./node_modules/.pnpm/[email protected]/node_modules/pg/lib/crypto/utils.js
Error: 
  x Return statement is not allowed here
    ,-[/Users/blog/node_modules/.pnpm/[email protected]/node_modules/pg/lib/crypto/utils.js:4:1]
  4 | if (useLegacyCrypto) {
  5 |   // We are on an old version of Node.js that requires legacy crypto utilities.
  6 |   module.exports = require('./utils-legacy')
  7 |   return
    :   ^^^^^^
  8 | }
  9 | 
 10 | const nodeCrypto = require('crypto')
    `----

Expected Behavior

Expect https://www.npmjs.com/package/pg to work

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

@lucgagan lucgagan added the bug Issue was opened via the bug report template. label Jun 7, 2023
@shuding
Copy link
Member

shuding commented Jun 8, 2023

This is an issue of that package, not related to Next.js: brianc/node-postgres#2980

@shuding shuding closed this as not planned Won't fix, can't repro, duplicate, stale Jun 8, 2023
@lucgagan
Copy link
Contributor Author

lucgagan commented Jun 8, 2023

This is hardly true.. It works just fine outside of Next.js.

I also tried using pg-promise and slonik and none of those worked.

@charmander
Copy link

This is an issue of that package, not related to Next.js: brianc/node-postgres#2980

As I noted in the linked issue, pg uses CommonJS modules, and top-level return is correct. pg will remove it, but this same bug will affect any other package that makes use of top-level return.

@gronka
Copy link

gronka commented Jul 24, 2023

This is an issue of that package, not related to Next.js: brianc/node-postgres#2980

I can't use pg-promise. Can you recommend a work-around?

@github-actions
Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template. locked
Projects
None yet
Development

No branches or pull requests

4 participants