Skip to content

dist/cjs/index.cjs not found in the dist package #845

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
hakatashi opened this issue Mar 20, 2025 · 6 comments · Fixed by #846
Closed

dist/cjs/index.cjs not found in the dist package #845

hakatashi opened this issue Mar 20, 2025 · 6 comments · Fixed by #846
Labels

Comments

@hakatashi
Copy link

hakatashi commented Mar 20, 2025

Describe the bug

PS C:\Users\hakatashi\Documents> mkdir temp_sql_formatter

    Directory: C:\Users\hakatashi\Documents

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d----          2025/03/20    17:06                temp_sql_formatter        

PS C:\Users\hakatashi\Documents> cd .\temp_sql_formatter\
PS C:\Users\hakatashi\Documents\temp_sql_formatter> npm install sql-formatter    

added 9 packages in 2s

1 package is looking for funding
  run `npm fund` for details
PS C:\Users\hakatashi\Documents\temp_sql_formatter> node                    
Welcome to Node.js v20.18.1.
Type ".help" for more information.
> require('sql-formatter')
Uncaught:
Error: Cannot find module 'C:\Users\hakatashi\Documents\temp_sql_formatter\node_modules\sql-formatter\dist\cjs\index.cjs'
    at createEsmNotFoundErr (node:internal/modules/cjs/loader:1262:15)      
    at finalizeEsmResolution (node:internal/modules/cjs/loader:1250:15)     
    at resolveExports (node:internal/modules/cjs/loader:634:14)
    at Module._findPath (node:internal/modules/cjs/loader:724:31)
    at Module._resolveFilename (node:internal/modules/cjs/loader:1211:27)   
    at Module._load (node:internal/modules/cjs/loader:1051:27)
    at Module.require (node:internal/modules/cjs/loader:1311:19)
    at require (node:internal/modules/helpers:179:18) {
  code: 'MODULE_NOT_FOUND',
  path: 'C:\\Users\\hakatashi\\Documents\\temp_sql_formatter\\node_modules\\sql-formatter\\package.json'
}
>

Expected behavior
requiring package succeeds without error in CJS environment

Actual behavior
Simply requiring package fails with error Error: Cannot find module '<cwd>/node_modules/sql-formatter/dist/cjs/index.cjs'

The main field of the distributed package.json specifies dist/cjs/index.cjs (https://npmfs.com/package/sql-formatter/15.5.0/package.json#L6), but it doesn't exist (https://npmfs.com/package/sql-formatter/15.5.0/dist/cjs/). Maybe it should be dist/cjs/index.js?

Usage

  • How are you calling / using the library?
    • dependency of firebase-tools
  • What SQL language(s) does this apply to?
    • N/A
  • Which SQL Formatter version are you using?
    • 15.5.0
@inxendere
Copy link

having this issue myself. any idea how to circumvent this?

@andre-huehn
Copy link

Resolving the version to 15.3.0 is a workaround, that we just put in place.

@eugeneford
Copy link

Having this issue myself in firebase-tools. Getting the following error:

eugenef@Eugenes-Macbook-Air ~ % firebase
node:internal/modules/cjs/loader:641
      throw e;
      ^

Error: Cannot find module '/Users/eugenef/.nvm/versions/node/v20.18.0/lib/node_modules/firebase-tools/node_modules/sql-formatter/dist/cjs/index.cjs'
    at createEsmNotFoundErr (node:internal/modules/cjs/loader:1262:15)
    at finalizeEsmResolution (node:internal/modules/cjs/loader:1250:15)
    at resolveExports (node:internal/modules/cjs/loader:634:14)
    at Module._findPath (node:internal/modules/cjs/loader:724:31)
    at Module._resolveFilename (node:internal/modules/cjs/loader:1211:27)
    at Module._load (node:internal/modules/cjs/loader:1051:27)
    at Module.require (node:internal/modules/cjs/loader:1311:19)
    at require (node:internal/modules/helpers:179:18)
    at Object.<anonymous> (/Users/eugenef/.nvm/versions/node/v20.18.0/lib/node_modules/firebase-tools/lib/dataconnect/schemaMigration.js:5:25)
    at Module._compile (node:internal/modules/cjs/loader:1469:14) {
  code: 'MODULE_NOT_FOUND',
  path: '/Users/eugenef/.nvm/versions/node/v20.18.0/lib/node_modules/firebase-tools/node_modules/sql-formatter/package.json'
}

Node.js v20.18.0

What shall I do?

@nezhaLee
Copy link

Related questions: #845

@wolfsokta
Copy link

@eugeneford - Manual fix is to copy index.js to index.cjs in that directory and firebase-tools will run correctly.

@Exac
Copy link

Exac commented Mar 20, 2025

@nene Hi Rene, it seems like the latest release has caused some issues. Related: firebase/firebase-tools#8343

@nene nene closed this as completed in #846 Mar 20, 2025
nene added a commit that referenced this issue Mar 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants