NODE_PATH error with node.js while attempting to setup jsctags for vim
Asked Answered
O

1

2

I am trying to setup doctorjs on my windows machine, to work with vim's tagbar, but I think this may be a node.js question more than anything else. I'm following this tutorial. Even after I set my NODE_PATH, I still get an error claiming that it needs to be set. What could be going wrong?

Here is a terminal log on my win7 machine:

C:\Windows\system32>set NODE_PATH=C:\Users\JG\Desktop\new\doctorjs\lib\jsctags

C:\Windows\system32>node.exe C:\Users\JG\Desktop\new\doctorjs\bin\jsctags.js -h
'node.exe' is not recognized as an internal or external command,
operable program or batch file.

C:\Windows\system32>cd c:\Users\JG\Desktop\new\doctorjs

c:\Users\JG\Desktop\new\doctorjs>node.exe C:\Users\JG\Desktop\new\doctorjs\bin\j
sctags.js -h

node.js:201
        throw e; // process.nextTick error, or 'error' event on first tick
              ^
Error: require.paths is removed. Use node_modules folders, or the NODE_PATH envi
ronment variable instead.
    at Function.<anonymous> (module.js:376:11)
    at Object.<anonymous> (C:\Users\JG\Desktop\new\doctorjs\bin\jsctags.js:41:8)

    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)

c:\Users\JG\Desktop\new\doctorjs>
Oz answered 5/12, 2011 at 11:49 Comment(0)
B
3

In node.js 0.6.x the require.paths has been removed. It has been deprecated since 0.2.x if I recall. So the problem isn't the lack of a NODE_PATH environment variable, but that the package / app you are running isn't compatible with node 0.6.x. Normal solution would be to run this app in node.js 0.4.12. Unfortunately there is no supported version of 0.4.x for Windows. Best bet is to rewrite the application so that require.paths isn't used anymore.

Furthermore: Don't start the app like node.exe C:\Full\Path\Folder, because the working directory will be C:\. Therefore do something like:

C:\Full\Path\Folder> C:\node.js\bin\node.exe Folder.
Backwater answered 5/12, 2011 at 13:18 Comment(7)
Hey Jan, thanks for replying. When you say rewrite the application, do you mean the ctags application that I am calling? I think all the path code occurs at the top of the file (see this snippet ). But I am a bit unclear about how to alter this code so the app would still work. Can you give some tips?Oz
You will have to change the paths to relative paths. So if 'underscore' is in the folder lib/underscore, your require should look like require("./lib/underscore"). Or, you should move all dependencies to the node_modules folder. Then you should delete the require.paths.unshift line.Backwater
Manually editing the require() calls is proving too difficult bc of nested require() calls, so I am attempting to move all dependencies to node_modules. I did the full nodejs msi install, and have tried putting the jsctags lib folder in "C:\Program Files (x86)\nodejs\node_modules\" as well as "C:\Program Files (x86)\nodejs\node_modules\npm\node_modules", but it's still not detecting the includes. What else do I need to do?Oz
You'll have to move the modules to the node_modules folder in the root of your project. not in the nodejs folder :-)Backwater
lol, ok, node.js newb obv. ok, so i'm making some progress but am getting one strange error/notice. so what i did was copy the contents of lib/jsctags folder into the folder node_modules, which as at my projects root (you can see the entire dir structure here: pastebin.com/F5nH3ung). I then issue this command. As you can see there is a warning about sys module now being "util," even though I have made these edits to "bin/jsctags.js". Any ideas? Does this need to be fixed?Oz
Can you put this project on Github or Bitbucket? Would make it easier for me to debug this.Backwater
Here are my changes. What I did was: moving everything from lib into node_modules. Removing all the paths.unshift, and setting the paths right myself. See this file.Backwater

© 2022 - 2024 — McMap. All rights reserved.