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

can someone help me i'm trying error in import , project in nextJs #433

Open
EdsonMateus1 opened this issue Aug 18, 2022 · 5 comments
Open

Comments

@EdsonMateus1
Copy link

./node_modules/web-tree-sitter/tree-sitter.js:1:747
Module not found: Can't resolve 'fs'

Import trace for requested module:
./node_modules/curlconverter/dist/src/bash-parser-web.js
./node_modules/curlconverter/dist/src/util.js
./node_modules/curlconverter/dist/src/index.js
./src/globals/components/dymanic-form/HTTPBodyField.tsx
./src/globals/components/dymanic-form/RenderTypeOfInput.tsx
./src/globals/components/dymanic-form/RenderForm.tsx
./src/views/builder/components/sidebar/tabs/actions/index.tsx
./src/views/builder/components/sidebar/DefaultNodeView/index.tsx
./src/views/builder/components/sidebar/index.tsx
./src/views/builder/index.tsx
./src/pages/builder/[id]/index.tsx

https://nextjs.org/docs/messages/module-not-found

@Shubham567
Copy link

I had faced that before, its probably because of some nodejs methods being called from browser environment.

I refered to this,
https://stackoverflow.com/questions/64926174/module-not-found-cant-resolve-fs-in-next-js-application

but even this didn't solve the issue,
after doing that i started to get this

error - ./node_modules/curlconverter/dist/src/bash-parser-web.js
Module parse failed: The top-level-await experiment is not enabled (set experiments.topLevelAwait: true to enabled it)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
Error: The top-level-await experiment is not enabled (set experiments.topLevelAwait: true to enabled it)
CCError: empty "program" node
    at tokenize (file:///C:/Users/shubh/WebstormProjects/shastra/node_modules/curlconverter/dist/src/util.js:886:15)

@72L
Copy link

72L commented Jul 19, 2023

I get a similar message:

- error ./node_modules/@curlconverter/tree-sitter/build/Release/tree_sitter_runtime_binding.node
Module parse failed: Unexpected character '�' (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
(Source code omitted for this binary file)

@verhovsky
Copy link
Member

verhovsky commented Jul 19, 2023

Try adding this to next.config.js:

module.exports = {
  webpack: (config) => {
    config.resolve.fallback = {
      ...config.resolve.fallback,
      fs: false,
      path: false
    };
    config.experiments = { 
      ...config.experiments,
      topLevelAwait: true
    };

    return config;
  },
};

The path: false line might be unnecessary.

@BhojrajPathak001
Copy link

can i do the same if i am using react app?

@Shubham567
Copy link

No, the webpack config for CRA is bit different. Though this issue is not supposed to happen in React app. I think you are using a library which is built for Node.js.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

5 participants