bun icon indicating copy to clipboard operation
bun copied to clipboard

error No "exports" main defined in /vercel/path0/node_modules/estree-walker/package.json

Open Achalogy opened this issue 2 years ago • 11 comments

What version of Bun is running?

1.0.13

What platform is your computer?

Vercel Deploy

What steps can reproduce the bug?

  • Astro v3.5.5
  • @astrojs/vercel^5.2.0

astro.config.mjs

// https://astro.build/config
export default defineConfig({
  integrations: [tailwind(), react()],
  output: "server",
  adapter: vercel({
    mode: "standalone"
  })
});
03:27:46 PM [build] Rearranging server assets...
03:27:46 PM [@astrojs/vercel/serverless] Bundling function ../../../../dist/entry.mjs 
error   No "exports" main defined in /vercel/path0/node_modules/estree-walker/package.json
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in /vercel/path0/node_modules/estree-walker/package.json
    at new NodeError (node:internal/errors:405:5)
    at exportsNotFound (node:internal/modules/esm/resolve:359:10)
    at packageExportsResolve (node:internal/modules/esm/resolve:639:13)
    at resolveExports (node:internal/modules/cjs/loader:567:36)
    at Module._findPath (node:internal/modules/cjs/loader:636:31)
    at Module._resolveFilename (node:internal/modules/cjs/loader:1063:27)
    at Module._load (node:internal/modules/cjs/loader:922:27)
    at Module.require (node:internal/modules/cjs/loader:1143:19)
    at require (node:internal/modules/cjs/helpers:121:18)
    at Object.<anonymous> (/vercel/path0/node_modules/@vercel/nft/out/analyze.js:7:25)
error: script "build" exited with code 1 (SIGHUP)
Error: Command "bun run build" exited with 1

The problem is at the time of execution of bun install, bun install is executed without error but after executing the build of the project, send the above mentioned error

What is the expected behavior?

Normal installation and correct operation in vercel

What do you see instead?

Deployment fails and it is necessary to switch to pnpm install or another package manager.

Additional information

No response

Achalogy avatar Nov 20 '23 15:11 Achalogy

Just to confirm, you're saying this works with pnpm? Could you also provide your package.json?

Electroid avatar Nov 20 '23 17:11 Electroid

{
  "name": "icfesu-front",
  "type": "module",
  "version": "0.0.1",
  "scripts": {
    "dev": "astro dev",
    "start": "astro dev",
    "build": "astro check && astro build",
    "preview": "astro preview",
    "astro": "astro"
  },
  "dependencies": {
    "@astrojs/check": "^0.3.0",
    "@astrojs/react": "^3.0.4",
    "@astrojs/tailwind": "^5.0.2",
    "@astrojs/vercel": "^5.2.0",
    "@tabler/icons-react": "^2.40.0",
    "@types/react": "^18.0.21",
    "@types/react-dom": "^18.0.6",
    "astro": "^3.4.0",
    "astro-icon": "^0.8.1",
    "react": "^18.0.0",
    "react-dom": "^18.0.0",
    "tailwindcss": "^3.0.24",
    "typescript": "^5.2.2"
  }
}

Yeah, with pnpm works, but slower.

Achalogy avatar Nov 21 '23 02:11 Achalogy

@Achalogy can you confirm that if you delete pnpm-lock* it continues to work with pnpm install?

Most likely, the package in use here is a version which does not support the ESM above, but the version in use by pnpm is one that does support the ESM in use above.

You could also set versions of relevant packages to "latest" and that would testi t

Jarred-Sumner avatar Nov 22 '23 03:11 Jarred-Sumner

@Jarred-Sumner I never used pnpm before in this project.

Achalogy avatar Nov 22 '23 03:11 Achalogy

I set all the versions to "latest" and now:

Running build in Washington, D.C., USA (East) – iad1 (Hive)
Cloning github.com/Achalogy/icfesu-front (Branch: master, Commit: 952bb28)
Cloning completed: 438.457ms
Restored build cache
Running "vercel build"
Vercel CLI 32.5.6
Installing dependencies...
bun install v1.0.13 (f5bf67bd)
 + @astrojs/[email protected]
 + @tabler/[email protected]
 + @types/[email protected]
 + @types/[email protected]
 + [email protected]
 + [email protected]
 550 packages installed [3.36s]
error: linking esbuild: FileNotFound
Running "bun run build"
$ astro check && astro build
file:///vercel/path0/node_modules/hast-util-raw/lib/index.js:56
import {Parser, Token, TokenizerMode, html} from 'parse5'
        ^^^^^^
SyntaxError: Named export 'Parser' not found. The requested module 'parse5' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:
import pkg from 'parse5';
const {Parser, Token, TokenizerMode, html} = pkg;
    at ModuleJob._instantiate (node:internal/modules/esm/module_job:124:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:190:5)
error: script "build" exited with code 1 (SIGHUP)
Error: Command "bun run build" exited with 1

package.json:

...
"dependencies": {
    "@astrojs/check": "latest",
    "@astrojs/react": "latest",
    "@astrojs/tailwind": "latest",
    "@astrojs/vercel": "latest",
    "@tabler/icons-react": "latest",
    "@types/react": "latest",
    "@types/react-dom": "latest",
    "astro": "latest",
    "astro-icon": "latest",
    "react": "latest",
    "react-dom": "latest",
    "tailwindcss": "latest",
    "typescript": "latest"
  }

Achalogy avatar Nov 22 '23 03:11 Achalogy

Re-deploy with pnpm package manager works (and no pnpm-lock)

https://pastebin.com/DncQp8EV <- build logs with pnpm

Achalogy avatar Nov 22 '23 03:11 Achalogy

Deleting bun.lockb, running pnpm install, and checking in pnpm-lock.yaml fixed this for me as well.

danscan avatar Jan 17 '24 15:01 danscan

I am getting this error too

juliomuhlbauer avatar Apr 03 '24 13:04 juliomuhlbauer

When can we this be fixed? I've been troubled for a long time

cworld1 avatar May 14 '24 09:05 cworld1

Seems like to force refresh building cache, can be of help to solve the problem, if it is shown on the Vercel building process. Hope it can help someone fix the problem.

cworld1 avatar May 20 '24 08:05 cworld1

Redeploying without checking "Use existing Build Cache" solved it for me too, thanks @cworld1.

Bun version: v1.1.8

Edit: just happened to me again! Solution was, again, to redeploy without using existing build cache. Bun version 1.1.17.

aczw avatar May 21 '24 06:05 aczw

Running into this all of a sudden as well with Bun on vercel. It's not been a problem for us until just recently but for now our solve is a redeploy without the build cache and thus far that has been the solution without exploring a more concrete reason.

Thanks for the band-aid suggestion above! Will look again later for an official resolution.

prodkt avatar Jun 13 '24 02:06 prodkt

The same thing was happening in AWS

2024-08-29T15:44:11.483Z [WARNING]: [error] No "exports" main defined in /codebuild/output/src588137643/src/Docs/node_modules/estree-walker/package.json
at new NodeError (node:internal/errors:405:5)
at exportsNotFound (node:internal/modules/esm/resolve:362:10)
at packageExportsResolve (node:internal/modules/esm/resolve:642:13)
at resolveExports (node:internal/modules/cjs/loader:567:36)
at Module._findPath (node:internal/modules/cjs/loader:636:31)
at Module._resolveFilename (node:internal/modules/cjs/loader:1063:27)
at Module._load (node:internal/modules/cjs/loader:922:27)
at Module.require (node:internal/modules/cjs/loader:1143:19)
at require (node:internal/modules/cjs/helpers:119:18)
at Object.<anonymous> (node_modules/@vue/compiler-core/dist/compiler-core.cjs.prod.js:13:20)
2024-08-29T15:44:11.483Z [WARNING]: [error] No "exports" main defined in /codebuild/output/src588137643/src/Docs/node_modules/estree-walker/package.json
2024-08-29T15:44:11.488Z [WARNING]: error: script "generate" exited with code 1
2024-08-29T15:44:11.490Z [ERROR]: !!! Build failed
2024-08-29T15:44:11.490Z [ERROR]: !!! Error: Command failed with exit code 1
2024-08-29T15:44:11.490Z [INFO]: # Starting environment caching...
2024-08-29T15:44:11.490Z [INFO]: # Uploading environment cache artifact...
2024-08-29T15:44:11.555Z [INFO]: # Uploaded environment cache artifact
2024-08-29T15:44:11.555Z [INFO]: # Environment caching completed

The solution was to remove the following from amplify.yml, which can be found in Hosting => Build Settings

cache:
  paths:
    - node_modules/**/*

Assuming you used the following amplify.yml bun script

JasonLandbridge avatar Aug 29 '24 15:08 JasonLandbridge

Just had the same problem with deploying astro.js version 4.16.7 with bun, @cworld1's solution worked! Redeployed without cache.

Niklex21 avatar Nov 03 '24 09:11 Niklex21

I also had the same problem with deploying astro.js on Vercel version 4.16.10 with bun, @cworld1's solution also worked!

EloToJaa avatar Nov 09 '24 15:11 EloToJaa

Consistently having this issue with Nuxt. This forced me to use pnpm for the time being, as I redeploying was only a one time fix, and new deployments would fail in the same way.

paranoidPhantom avatar Dec 20 '24 16:12 paranoidPhantom

To add onto @cworld1 solution, you can add this environment variable to your vercel project to skip the build cache on all builds:

VERCEL_FORCE_NO_BUILD_CACHE=1

gnosticdev avatar Feb 01 '25 22:02 gnosticdev