简体   繁体   中英

Error: Cannot find module 'curl' at Function.Module._resolveFilename (module.js:489:15)

I installed node.js with the windows installer. The folder structure formed is C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules . The last node_modules has all the module folders I guess.

I use the node.js command prompt to execute my js script. When the script is on Desktop, it executes all fine. When I shift my script to another folder in my C: it gives the error. I don't want to give the absolute path as it will have to be changed again and again. Anyways, what path should I give as absolute to make it just work

Error: Cannot find module 'curl'
    at Function.Module._resolveFilename (module.js:489:15)

I have gone through the resolutions mentioned in other discussions. Have made the NODE_PATH environment variable. Have edited PATH variable to make it C:\\Program Files\\nodejs and not C:\\Program Files\\nodejs\\ . Have executed npm install -g npm and nothing seems to work.

Sorry for the trouble, if anyone has already started looking into it. I found the solution. In the node.js command prompt, in the project folder I executed the following 'npm install curl' which downloaded the curl packages into a node_modules folder in the folder which has my script. I anyways wonder, then how it worked when I had placed my project on Desktop. It seems that the way node.js finds modules has to be checked. FYI - I have not set the NODE_PATH and the path still has C:\\Program Files\\nodejs\\ after I freshly installed it. Thank you!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM