npm start crashed on typescript project
See original GitHub issueI’ve created a basic TS project when trying to import article-parser project I’m getting the following error:
2022-08-13 11:14:10 error: uncaughtException: require() of ES Module /Users/myname/private/myprojectname-server/node_modules/article-parser/src/main.js from /Users/myname/private/myprojectname-server/src/services/dataExtracting.service.ts not supported.
Instead change the require of main.js in /Users/myname/private/myprojectname-server/src/services/dataExtracting.service.ts to a dynamic import() which is available in all CommonJS modules.
Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/myname/private/myprojectname-server/node_modules/article-parser/src/main.js from /Users/myname/private/myprojectname-server/src/services/dataExtracting.service.ts not supported.
Instead change the require of main.js in /Users/myname/private/myprojectname-server/src/services/dataExtracting.service.ts to a dynamic import() which is available in all CommonJS modules.
at Object.require.extensions.<computed> [as .js] (/Users/myname/private/myprojectname-server/node_modules/ts-node/dist/index.js:851:20)
at Object.<anonymous> (/Users/myname/private/myprojectname-server/src/services/dataExtracting.service.ts:4:26)
at Module.m._compile (/Users/myname/private/myprojectname-server/node_modules/ts-node/dist/index.js:857:29)
at Object.require.extensions.<computed> [as .ts] (/Users/myname/private/myprojectname-server/node_modules/ts-node/dist/index.js:859:16)
at Object.<anonymous> (/Users/myname/private/myprojectname-server/src/controllers/facts.controller.ts:4:34)
at Module.m._compile (/Users/myname/private/myprojectname-server/node_modules/ts-node/dist/index.js:857:29)
at Object.require.extensions.<computed> [as .ts] (/Users/myname/private/myprojectname-server/node_modules/ts-node/dist/index.js:859:16)
at Object.<anonymous> (/Users/myname/private/myprojectname-server/src/routes/facts.route.ts:5:52)
at Module.m._compile (/Users/myname/private/myprojectname-server/node_modules/ts-node/dist/index.js:857:29)
at Object.require.extensions.<computed> [as .ts] (/Users/myname/private/myprojectname-server/node_modules/ts-node/dist/index.js:859:16)
at Object.<anonymous> (/Users/myname/private/myprojectname-server/src/server.ts:9:47)
at Module.m._compile (/Users/myname/private/myprojectname-server/node_modules/ts-node/dist/index.js:857:29)
at Object.require.extensions.<computed> [as .ts] (/Users/myname/private/myprojectname-server/node_modules/ts-node/dist/index.js:859:16)
at phase4 (/Users/myname/private/myprojectname-server/node_modules/ts-node/dist/bin.js:466:20)
at bootstrap (/Users/myname/private/myprojectname-server/node_modules/ts-node/dist/bin.js:54:12)
at main (/Users/myname/private/myprojectname-server/node_modules/ts-node/dist/bin.js:33:12)
at Object.<anonymous> (/Users/myname/private/myprojectname-server/node_modules/ts-node/dist/bin.js:579:5)
Issue Analytics
- State:
- Created a year ago
- Comments:6
Top Results From Across the Web
npm run watch crashes after any change in vue or js files ...
Both npm run dev and prod works properly, however when I try to run watch, and change files, npm run watch throws an...
Read more >Brower crashes when running Typescript application #19510
Brower crashes when running Typescript application #19510 ... The app will run as expected when running the npm run dev task.
Read more >Typescript Basic Node.js Express app crashes at launch
It's working now. In the project's solution explorer is a node named "nmp", open the node. In this node are 3 packages, namely...
Read more >Let It Crash: Best Practices for Handling Node.js Errors on ...
It's simpler to let it crash, start a new process from scratch, and continue receiving more requests. We're explicitly “crashing” the Node. js ......
Read more >ts-node-dev - npm
Start using ts-node-dev in your project by running `npm i ... files changes (as standard node-dev ) but shares Typescript compilation ...
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 FreeTop 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
Top GitHub Comments
@ndaidong Sure
my package.json file:
My tsConfig.ts file:
My service:
My app.ts file
@israelor6 it seems you are using
require
to import. Could you try commonjs syntax?