remy / nodemon

Monitor for any changes in your node.js application and automatically restart the server - perfect for development
http://nodemon.io/
MIT License
26.34k stars 1.74k forks source link

Import error when use type module on package.json #2217

Closed Pnlvfx closed 3 weeks ago

Pnlvfx commented 3 months ago

This expression is not callable. Type 'typeof import("/Users/simo97/Desktop/web/tiktok-downloader/node_modules/nodemon/index")' has no call signatures.ts(2349)

I'm using latest version but it happeng from 3.1.0, as no one has reported it before, I will do it.

Pnlvfx commented 3 months ago

Typescript tell you to use nodemon.default, but then when starting nodemon, node will throw an error as nodemon.default is not a function, so there is something wrong between types and export

github-actions[bot] commented 2 months ago

This issue has been automatically marked as idle and stale because it hasn't had any recent activity. It will be automtically closed if no further activity occurs. If you think this is wrong, or the problem still persists, just pop a reply in the comments and @remy will (try!) to follow up. Thank you for contributing <3

Pnlvfx commented 2 months ago

type: 'module' devDependency: { "nodemon": "^3.1.4", }

nodemon({ script: './dist/server.js', ext: 'js', exec: NGROK_URL=${url} node, })

This expression is not callable. Type 'typeof import("/Users/simo97/Desktop/web/node_modules/nodemon/index")' has no call signatures.ts(2349)

remy commented 2 months ago

I don't know what that means. Can you provide a git repo to help understand and replicate (note that I don't generally use typescript so assume you'll have to be clear in your instructions)

Pnlvfx commented 2 months ago

I understand, it's the same for me when I look at your project, I start coding using typescript and I never used module exports and stuff like that, so I really don't know how to help you, however, I think you know the difference between commonjs and esmodule.

import statements of .js files are treated as ES modules if the nearest parent package.json contains "type": "module".

Importing nodemon with type: module in a package.json will throw a typescript import error.

This expression is not callable. Type 'typeof import("/Users/simo97/Desktop/web/sports/api-jupiter/node_modules/nodemon/index")' has no call signatures.ts(2349)

I've seen that in the latest versions (I don't remember exactly which one) you include the @types in the repository, I strongly think that the error arises for that, however I'm not sure.

I'm sorry but I have no time to provide a repro, however you can just create a new typescript project and use type: module on your package.json and the error will appear.

Pnlvfx commented 2 months ago

I don't know what that means. Can you provide a git repo to help understand and replicate (note that I don't generally use typescript so assume you'll have to be clear in your instructions)

Sorry, but I have just seen that there is a pull request that address this issue,

https://github.com/remy/nodemon/pull/2211

remy commented 2 months ago

I've just merged that pr. Since it was provided by someone else it didn't come with tests, so I can't be entirely sure it does what helps you, but hopefully it does the trick.

Pnlvfx commented 2 months ago

I've just merged that pr. Since it was provided by someone else it didn't come with tests, so I can't be entirely sure it does what helps you, but hopefully it does the trick.

I'l try it now and let you know if it does.

Pnlvfx commented 2 months ago

I've just merged that pr. Since it was provided by someone else it didn't come with tests, so I can't be entirely sure it does what helps you, but hopefully it does the trick.

Yes, it does fix the issue.

github-actions[bot] commented 1 month ago

This issue has been automatically marked as idle and stale because it hasn't had any recent activity. It will be automtically closed if no further activity occurs. If you think this is wrong, or the problem still persists, just pop a reply in the comments and @remy will (try!) to follow up. Thank you for contributing <3

github-actions[bot] commented 3 weeks ago

Automatically closing this issue due to lack of activity