Skip to content

Next.s 9 | API | graphql - Can't resolve 'fs' in /api/index.ts #8134

@mzygmunt

Description

@mzygmunt

Examples bug report

Example name

api-routes-graphql

Describe the bug

When I changed the name of the GraphQL API file from /api/graphql.js to /api/index.js, I noticed that the following error appears when building (after executing next build)

Failed to compile.
./node_modules/busboy/lib/main.js
Module not found: Can't resolve 'fs' in '/Users/mzygmunt/apps/next.js/examples/api-routes-graphql/node_modules/busboy/lib'
Build error occurred
Error: > Build failed because of webpack errors
at build (/Users/mzygmunt/apps/next.js/examples/api-routes-graphql/node_modules/next/dist/build/index.js:6:847)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! api-routes-graphql@1.0.0 build: next build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the api-routes-graphql@1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/mzygmunt/.npm/_logs/2019-07-27T09_46_44_792Z-debug.log

To Reproduce

  1. Clone example api-routes-graphql
  2. Change filename /api/graphql.js to /api/index.js
  3. Execure npm run build
  4. See error

Expected behavior

After changing the file name, API should be available at /api.

Screenshots

image

System information

  • OS: macOS
  • Browser (if applies) chrome
  • Version of Next.js: 9.0.2 - 9.0.3-canary.3

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions