Skip to content
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

API(8.1.1-canary.28): error logged when importing child_process #7334

Closed
Janpot opened this issue May 14, 2019 · 8 comments
Closed

API(8.1.1-canary.28): error logged when importing child_process #7334

Janpot opened this issue May 14, 2019 · 8 comments
Assignees

Comments

@Janpot
Copy link
Contributor

Janpot commented May 14, 2019

Bug report

Describe the bug

Errors are shown in the logs when trying to import child_process in an api function.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Create an api function
// /pages/api/hello.js
import 'child_process';
export default (req, res) => {
  res.end('hello');
};
  1. start next dev server
  2. visit http://localhost:3000/api/hello in the browser
  3. See error
[ error ] ./pages/api/hello.js
Module not found: Can't resolve 'child_process' in '<project-root>/pages/api'

Expected behavior

No error

Screenshots

If applicable, add screenshots to help explain your problem.

System information

  • OS: macOS
  • Version of Next.js: 8.1.1-canary.28

Additional context

Functionally there doesn't seem to be any problem, looks like it's just a logging problem.

@Janpot Janpot changed the title API(8.1.1-canary.28): Module not found: Can't resolve 'child_process' in '.../pages/api' API(8.1.1-canary.28): error logged when importing child_process May 14, 2019
@huv1k huv1k self-assigned this May 14, 2019
@Janpot
Copy link
Contributor Author

Janpot commented May 14, 2019

Functionally there doesn't seem to be any problem, looks like it's just a logging problem.

Actually, there is a problem, this seems to break rendering all the pages, with the same error.

@timneutkens
Copy link
Member

Note that you're using experimental features. This in particular is caused by the /api implementation not being complete yet.

@Janpot
Copy link
Contributor Author

Janpot commented May 16, 2019

I'm aware, just test driving new features. I can hold off on opening a ticket like this if you think it's too early, or report somewhere else.

@huv1k
Copy link
Contributor

huv1k commented Jun 8, 2019

This is fixed in latest canary 🚀

@huv1k huv1k closed this as completed Jun 8, 2019
@aaahrens
Copy link

I am getting this error again in canary of 9. Any advice?

@IMax153
Copy link

IMax153 commented Oct 30, 2019

@huv1k I am also running into the same issue trying to integrate the GraphQL API endpoints example with Prisma2. The query engine, PhotonJS, seems to depend on 'child_process', which results in an error every time I hit the GraphQL endpoint (or any other endpoint that attempts to use PhotonJS).


ModuleNotFoundError: Module not found: Error: Can't resolve 'child_process' in '/Users/maxbrown/Documents/projects/apps/iudex-next/node_modules/@generated/photon/runtime'
    at /Users/maxbrown/Documents/projects/apps/iudex-next/node_modules/webpack/lib/Compilation.js:888:10
    at /Users/maxbrown/Documents/projects/apps/iudex-next/node_modules/webpack/lib/NormalModuleFactory.js:401:22
    at /Users/maxbrown/Documents/projects/apps/iudex-next/node_modules/webpack/lib/NormalModuleFactory.js:130:21
    at /Users/maxbrown/Documents/projects/apps/iudex-next/node_modules/webpack/lib/NormalModuleFactory.js:224:22
    at /Users/maxbrown/Documents/projects/apps/iudex-next/node_modules/neo-async/async.js:2830:7
    at /Users/maxbrown/Documents/projects/apps/iudex-next/node_modules/neo-async/async.js:6877:13
    at /Users/maxbrown/Documents/projects/apps/iudex-next/node_modules/webpack/lib/NormalModuleFactory.js:214:25
    at /Users/maxbrown/Documents/projects/apps/iudex-next/node_modules/enhanced-resolve/lib/Resolver.js:213:14
    at /Users/maxbrown/Documents/projects/apps/iudex-next/node_modules/enhanced-resolve/lib/Resolver.js:285:5
    at eval (eval at create (/Users/maxbrown/Documents/projects/apps/iudex-next/node_modules/tapable/lib/HookCodeFactory.js:33:10), :15:1)
    at /Users/maxbrown/Documents/projects/apps/iudex-next/node_modules/enhanced-resolve/lib/UnsafeCachePlugin.js:44:7
    at /Users/maxbrown/Documents/projects/apps/iudex-next/node_modules/enhanced-resolve/lib/Resolver.js:285:5
    at eval (eval at create (/Users/maxbrown/Documents/projects/apps/iudex-next/node_modules/tapable/lib/HookCodeFactory.js:33:10), :15:1)
    at /Users/maxbrown/Documents/projects/apps/iudex-next/node_modules/enhanced-resolve/lib/Resolver.js:285:5
    at eval (eval at create (/Users/maxbrown/Documents/projects/apps/iudex-next/node_modules/tapable/lib/HookCodeFactory.js:33:10), :27:1)
    at /Users/maxbrown/Documents/projects/apps/iudex-next/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js:67:43
ModuleNotFoundError: Module not found: Error: Can't resolve 'child_process' in '/Users/maxbrown/Documents/projects/apps/iudex-next/node_modules/@generated/photon/runtime'
    at /Users/maxbrown/Documents/projects/apps/iudex-next/node_modules/webpack/lib/Compilation.js:888:10
    at /Users/maxbrown/Documents/projects/apps/iudex-next/node_modules/webpack/lib/NormalModuleFactory.js:401:22
    at /Users/maxbrown/Documents/projects/apps/iudex-next/node_modules/webpack/lib/NormalModuleFactory.js:130:21
    at /Users/maxbrown/Documents/projects/apps/iudex-next/node_modules/webpack/lib/NormalModuleFactory.js:224:22
    at /Users/maxbrown/Documents/projects/apps/iudex-next/node_modules/neo-async/async.js:2830:7
    at /Users/maxbrown/Documents/projects/apps/iudex-next/node_modules/neo-async/async.js:6877:13
    at /Users/maxbrown/Documents/projects/apps/iudex-next/node_modules/webpack/lib/NormalModuleFactory.js:214:25
    at /Users/maxbrown/Documents/projects/apps/iudex-next/node_modules/enhanced-resolve/lib/Resolver.js:213:14
    at /Users/maxbrown/Documents/projects/apps/iudex-next/node_modules/enhanced-resolve/lib/Resolver.js:285:5
    at eval (eval at create (/Users/maxbrown/Documents/projects/apps/iudex-next/node_modules/tapable/lib/HookCodeFactory.js:33:10), :15:1)
    at /Users/maxbrown/Documents/projects/apps/iudex-next/node_modules/enhanced-resolve/lib/UnsafeCachePlugin.js:44:7
    at /Users/maxbrown/Documents/projects/apps/iudex-next/node_modules/enhanced-resolve/lib/Resolver.js:285:5
    at eval (eval at create (/Users/maxbrown/Documents/projects/apps/iudex-next/node_modules/tapable/lib/HookCodeFactory.js:33:10), :15:1)
    at /Users/maxbrown/Documents/projects/apps/iudex-next/node_modules/enhanced-resolve/lib/Resolver.js:285:5
    at eval (eval at create (/Users/maxbrown/Documents/projects/apps/iudex-next/node_modules/tapable/lib/HookCodeFactory.js:33:10), :27:1)
    at /Users/maxbrown/Documents/projects/apps/iudex-next/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js:67:43

@huv1k
Copy link
Contributor

huv1k commented Oct 31, 2019

This is most likely how is photon getting the path to the binary. I think it uses __dirname to resolve paths to binary. Next.js it's not working with __dirname yet #8251 But I am not 100% sure, didn't check how exactly photo binary resolution works.

@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 31, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants