Generated package imports missing .js file extension
See original GitHub issueI’m submitting a…
- bug
- feature
- chore
What is the current behavior
Create a new project npx bug-demo create-next-app --ts --use-npm
Add react-financial-charts, and add a chart to the home page
Running the project npm start dev
throws the following runtime error:
Error [ERR_MODULE_NOT_FOUND]: Cannot find module ‘.\node_modules@react-financial-charts\annotations\lib\Annotate’ imported from .\node_modules@react-financial-charts\annotations\lib\index.js
What is the expected behavior
Package imports should be built with .js
Please tell us about your environment
- node 16.13.1
- npm 8.2.0
"name": "bug-demo",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"d3-format": "^3.1.0",
"d3-time-format": "^4.1.0",
"next": "12.0.7",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-financial-charts": "^1.3.2"
},
"devDependencies": {
"@types/d3-format": "^3.0.1",
"@types/d3-time-format": "^4.0.0",
"@types/node": "16.11.12",
"@types/react": "17.0.37",
"eslint": "8.4.1",
"eslint-config-next": "12.0.7",
"typescript": "4.5.2"
}
}
Other information
Personally, I feel like this is a Typescript issue, but they seem adamant that this is by design and the resolution should be to add .js file extensions to all imports: https://github.com/microsoft/TypeScript/issues/40878
Issue Analytics
- State:
- Created 2 years ago
- Reactions:4
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Compiled JavaScript import is missing file extension #40878
Expected behavior: The compiler generates JavaScript "which runs anywhere JavaScript runs: In a browser, on Node.
Read more >Typescript import are missing the .js extension when it ...
I have decided to migrate my js project into ts, however I am faced with the following problem: all imports in ts files...
Read more >The Three Easiest Ways to Fix the "Missing File Extension 'tsx ...
1 How to Allow tsx File Extensions Using webpack.config.js ... The problem is, if you generate your app using create-react-app then ...
Read more >Auto import | WebStorm Documentation
Basic procedures to create and optimize imports in WebStorm. Learn more how to import the missing import or XML namespace.
Read more >API - esbuild
#Format. Supported by: Transform | Build. This sets the output format for the generated JavaScript files. There are currently three possible values that...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@eberlitz I have a PR to fix the file extensions, but next still has issues with ESM modules and webpack 5 still had issues with how this is packaged and I was getting a bunch of
Cannot read property 'isRequired' of undefined
based on the PropTypes. I was finally able to getreact-financial-charts
to work with next 11 & 12 without any changes to the latest release (1.3.2) using the following next config compose:You can exclude the d3 stuff depending on if you’re using that or not.
I’m also affected by this issue. I cannot build @react-financial-chart/* packages because of this issue.