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

ChordSheetJs v5.1.2 and react 17.0.2 got error #426

Closed
alexaung opened this issue Jan 11, 2022 · 3 comments
Closed

ChordSheetJs v5.1.2 and react 17.0.2 got error #426

alexaung opened this issue Jan 11, 2022 · 3 comments

Comments

@alexaung
Copy link

I got the following error after I import import ChordSheetJS from "chordsheetjs";

Compiled with problems:X

ERROR in ./node_modules/handlebars/lib/index.js 15:11-24

Module not found: Error: Can't resolve 'fs' in '/Users/zzzzz/Development/chordsheep/node_modules/handlebars/lib'

@martijnversluis
Copy link
Owner

Hey @alexaung. Thanks for reporting your issue.

Could you maybe describe your build setup, or link your project on GitHub/Gitlab? That could help me trying to figure out your error.

@alexaung
Copy link
Author

npx create-react-app my-app
cd my-app
yarn start
yarn add chordsheetjs
import in app.js

That all I did but could not build.

But I create the project with vitejs, this error is gone.

@danielsarin
Copy link

danielsarin commented Feb 5, 2022

I had the same issue with Next.js. I think it's related to this handlebars-lang/handlebars.js#1174.

The error was:

error - ./node_modules/handlebars/lib/index.js:17:0
Module not found: Can't resolve 'fs'

Import trace for requested module:
./node_modules/chordsheetjs/lib/formatter/html_table_formatter.js
./node_modules/chordsheetjs/lib/index.js
./songs/getFormattedSong.ts
./songs/index.ts
./components/songs/SongsTable.tsx
./components/songs/index.ts
./pages/songs/[slug].tsx

I fixed it by adding a custom webpack config:

module.exports = {
  webpack: (config) => {
    config.resolve.alias = {
      ...config.resolve.alias,
      handlebars: 'handlebars/dist/handlebars.min.js'
    };
    return config;
  }
};

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

No branches or pull requests

3 participants