It’s weird I have a little request (in nodejs) ( request_working.js ) that require the request module
The problem is that it works only in some folder because otherwise the module is not found!
For example my folders are this way :
/home/lol/Desktop/nodejs/ newProject/newProject/node_modules
So node request_working.js work in the bold folders (working in the nodejs and newProject folder but not in the other newProject folder or in node_modules folder)
Because I have this error :
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
TypeError: Object #<Object> has no method 'post'
at Object.<anonymous> (/home/lol/Desktop/nodejs/newProject/newProject/request_working.js:3:9)
at Module._compile (module.js:432:26)
at Object..js (module.js:450:10)
at Module.load (module.js:351:31)
at Function._load (module.js:310:12)
at Array.0 (module.js:470:10)
at EventEmitter._tickCallback (node.js:192:40)
Like if I didn’t have request module. (I am using a POST method from the request module)
I am using Express.js ( the newProject folder = Express project ) so I want to put my request_working.js in
/home/lol/Desktop/nodejs/newProject/newProject/node_modules
to use it as a module.
But how wan I fix this error first ?
Thanks !
Thanks david, it’s working !
How to fix this error ? :
in console type :
nodethen
moduleIt should gives you all the node_modules folders,
for example:
home/lol/newproject/node_modulesthen go in the folder
newprojectif it does not already existcreate a new foldernode_modules, put you modules in this folder and delete everynode_modulesdeeper in the directory example you should delete:home/lol/newproject/newproject/node_modulesTHanks again !