nodemon icon indicating copy to clipboard operation
nodemon copied to clipboard

Import error when use type module on package.json

Open Pnlvfx opened this issue 1 year ago • 10 comments

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 avatar Aug 28 '24 18:08 Pnlvfx

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

Pnlvfx avatar Aug 28 '24 18:08 Pnlvfx

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] avatar Sep 11 '24 19:09 github-actions[bot]

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)

Pnlvfx avatar Sep 16 '24 07:09 Pnlvfx

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)

remy avatar Sep 16 '24 08:09 remy

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 avatar Sep 20 '24 17:09 Pnlvfx

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

Pnlvfx avatar Sep 20 '24 17:09 Pnlvfx

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.

remy avatar Sep 20 '24 17:09 remy

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 avatar Sep 20 '24 17:09 Pnlvfx

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.

Pnlvfx avatar Sep 20 '24 17:09 Pnlvfx

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] avatar Oct 04 '24 18:10 github-actions[bot]

Automatically closing this issue due to lack of activity

github-actions[bot] avatar Nov 03 '24 18:11 github-actions[bot]