tailwind-nextjs-starter-blog icon indicating copy to clipboard operation
tailwind-nextjs-starter-blog copied to clipboard

Build Failed Command - "npm run build" exited with 1

Open jschof1 opened this issue 3 years ago • 1 comments

Unable to deploy app on Vercal

[10:44:19.228] Cloning github.com/jschof1/my-daily-blog (Branch: main, Commit: 6de7271)
[10:44:20.230] Cloning completed: 1.002s
[10:44:20.608] No Build Cache available
[10:44:20.653] Running "vercel build"
[10:44:21.296] Vercel CLI 28.2.2
[10:44:21.686] Installing dependencies...
[10:44:23.181] npm WARN old lockfile 
[10:44:23.181] npm WARN old lockfile The package-lock.json file was created with an old version of npm,
[10:44:23.181] npm WARN old lockfile so supplemental metadata must be fetched from the registry.
[10:44:23.181] npm WARN old lockfile 
[10:44:23.181] npm WARN old lockfile This is a one-time fix-up, please be patient...
[10:44:23.182] npm WARN old lockfile 
[10:44:45.718] npm WARN deprecated [email protected]: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility
[10:44:50.502] npm WARN deprecated [email protected]: Please upgrade to latest, formidable@v2 or formidable@v3! Check these notes: https://bit.ly/2ZEqIau
[10:44:52.328] npm WARN deprecated [email protected]: Please upgrade to v7.0.2+ of superagent.  We have fixed numerous issues with streams, form-data, attach(), filesystem errors not bubbling up (ENOENT on attach()), and all tests are now passing.  See the releases tab for more information at <https://github.com/visionmedia/superagent/releases>.
[10:45:04.682] npm WARN deprecated [email protected]: core-js-pure@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js-pure.
[10:45:07.929] 
[10:45:07.929] > [email protected] prepare
[10:45:07.930] > husky install
[10:45:07.930] 
[10:45:08.015] husky - Git hooks installed
[10:45:08.045] 
[10:45:08.045] added 1324 packages in 46s
[10:45:08.045] 
[10:45:08.045] 319 packages are looking for funding
[10:45:08.045]   run `npm fund` for details
[10:45:08.083] Detected Next.js version: 12.2.2
[10:45:08.100] Detected `package-lock.json` generated by npm 7+...
[10:45:08.100] Running "npm run build"
[10:45:08.483] 
[10:45:08.483] > [email protected] build
[10:45:08.484] > next build && node ./scripts/generate-sitemap
[10:45:08.484] 
[10:45:09.013] Attention: Next.js now collects completely anonymous telemetry regarding usage.
[10:45:09.014] This information is used to shape Next.js' roadmap and prioritize features.
[10:45:09.014] You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
[10:45:09.014] https://nextjs.org/telemetry
[10:45:09.014] 
[10:45:09.142] info  - Linting and checking validity of types...
[10:45:13.666] 
[10:45:13.666] ./pages/api/klaviyo.js
[10:45:13.667] 1:1  Warning: Assign arrow function to a variable before exporting as module default  import/no-anonymous-default-export
[10:45:13.667] 
[10:45:13.667] info  - Need to disable some ESLint rules? Learn more here: https://nextjs.org/docs/basic-features/eslint#disabling-rules
[10:45:13.670] info  - Creating an optimized production build...
[10:45:17.062] Browserslist: caniuse-lite is outdated. Please run:
[10:45:17.062]   npx browserslist@latest --update-db
[10:45:17.063]   Why you should do it regularly: https://github.com/browserslist/browserslist#browsers-data-updating
[10:45:45.305] Failed to compile.
[10:45:45.306] 
[10:45:45.306] ./node_modules/mdx-bundler/dist/client.js
[10:45:45.306] Module not found: Package path ./compat/jsx-runtime.js is not exported from package /vercel/path0/node_modules/preact (see exports field in /vercel/path0/node_modules/preact/package.json)
[10:45:45.306] 
[10:45:45.306] Import trace for requested module:
[10:45:45.307] ./node_modules/mdx-bundler/client/index.js
[10:45:45.307] ./components/MDXComponents.js
[10:45:45.307] ./pages/about.js
[10:45:45.307] 
[10:45:45.307] 
[10:45:45.308] > Build failed because of webpack errors
[10:45:45.359] Error: Command "npm run build" exited with 1

jschof1 avatar Sep 08 '22 09:09 jschof1

Module not found: Package path ./compat/jsx-runtime.js is not exported from package /vercel/path0/node_modules/preact (see exports field in /vercel/path0/node_modules/preact/package.json)

It seems that for some reason Preact is not found. Could you try updating your preact version and next.config.js to match the current master? Otherwise, if you don't mind not using Preact, you can remove these lines and it should work.

timlrx avatar Sep 09 '22 16:09 timlrx

Thank for your help, I finally managed to get it deployed!

Steps to fixing:

  1. Updated package.json by replacing the one I was using with the one in the latest version of this repo.
  2. Replaced the next.config.js with the latest repo.
  3. Still having the same problem so I made some changes to the next.config.js changing this
 webpack: (config, { dev, isServer }) => {
    config.module.rules.push({
      test: /\.svg$/,
      use: ['@svgr/webpack'],
    })

To this

webpack: (config, { dev, isServer }) => {
    (config.resolve.alias = {
      ...config.resolve.alias,
      // fixes next-mdx-remote: Package path ./jsx-runtime.js is not exported from package react
      // https://github.com/hashicorp/next-mdx-remote/issues/237
      'react/jsx-runtime.js': require.resolve('react/jsx-runtime'),
    }),
      config.module.rules.push({
        test: /\.svg$/,
        use: ['@svgr/webpack'],
      })
  1. but then it was still failing to build (!) because of the prettier extension so I ran this in my root directory

npm run lint --fix

Ta da! What a relief.

jschof1 avatar Oct 05 '22 14:10 jschof1