node 5.x : require.paths is removed #320

olostan opened this Issue Jul 17, 2011 · 33 comments


None yet
olostan commented Jul 17, 2011

I tried to use less.js with lastest node.js (v0.5.2-pre) and got this

    Error: require.paths is removed. Use node_modules folders, or the NODE_PATH environment variable instead.
        at Function.<anonymous> (module.js:360:11)
        at Object.<anonymous> (/home/olostan/node_modules/less/lib/less/index.js:5:8)
        at Module._compile (module.js:420:26)

In index.js there is line:
require.paths.unshift(path.join(__dirname, '..'));
that raises this error.

As I understand there is no possibility to simple refactor less.js code to remove usage of require.paths. Or there is some way?


I can't use command line because of this reason. How can I get a stable version so I can just use a command line to compile .less to .css? Ruby gem is not compiling it either. Help?

olostan commented Jul 18, 2011

I am using less with node 5.2 such way:

  1. Comment line require.paths.unshift(path.join(__dirname, '..')); in index.js in Less (search in node_modules/less folder)
  2. created .sh file with such content:
    NODE_PATH=pwd'/node_modules/less/lib' node-dev app.js

This put path to Less files to NODE_PATH variable and runs node-dev that runs my app.

Hope there would not be need of this workaround soon, but meanwhile you can try to do same - just put path to Less into NODE_PATH variable.

@olostan olostan closed this Jul 18, 2011
@olostan olostan reopened this Jul 18, 2011

Thanks. However I found lessphp and it's working..

In Emacs, I use shell-command to convert .less file to .css. It's working so far.

enzy commented Jul 28, 2011

Thanks @olostan, as temporary fix its good enough :)

EyePulp commented Aug 2, 2011

Here's how I got this working - I'm using node@v0.5.3-pre on OSX with npm@1.0.9-1 and installed less globally via npm:

  1. edit the lessc file - mine was here: /Users/eyepulp/bin/node/bin/lessc (you can use which lessc to find your location) -- comment out line 7 - // require.paths.unshift(path.join(__dirname, '..', 'lib')); -- save/close the file
  2. edit the index.js file - mine was here: /Users/eyepulp/bin/node/lib/node_modules/less/lib/less/index.js -- comment out line 5 - // require.paths.unshift(path.join(__dirname, '..')); -- save/close the file
  3. edit your ~/.bashrc or ~/.profile or whatever sets your command line environment and update your $NODE_PATH (modify for your paths):
# Node.js library paths:
export NODE_PATH=/Users/eyepulp/bin/node/lib/node_modules:$NODE_PATH
export NODE_PATH=/Users/eyepulp/bin/node/lib/node_modules/less/lib:$NODE_PATH

If you're using the lessc command within TextMate, make sure you stick those same paths in the TM environment variables:

  1. Go to TextMate>Preferences>Shell Variables
  2. Add/Update a NODE_PATH variable with the same two paths (colon delimited): /Users/eyepulp/bin/node/lib/node_modules:/Users/eyepulp/bin/node/lib/node_modules/less/lib
olostan commented Aug 2, 2011

Unfortunally is it only workaround like I did.... hoping somebody good in LessJS code will actually fix this :)

EyePulp commented Aug 2, 2011

Yeah, I certainly don't have a better solution. I just didn't have an easy time figuring out the $NODE_PATH solution, so I wrote it down for other luck-less folks... =)


The workaround is working fine, but you don't need the first line on your .profile, just needed is:

Node.js library paths:

export NODE_PATH=/Users/eyepulp/bin/node/lib/node_modules/less/lib:$NODE_PATH

kixxauth commented Sep 7, 2011

possible fix in the tree here: #377


Pull; and let me know if there are undiscovered issues.

swparr commented Oct 26, 2011

Help!, I'm running node v0.5.5, npm v1.0.6 and coffee-script version 1.1.2, but I keep getting this exception. I've tried the code changes above but no luck!

→ coffee
coffee> 1+1
Error: require.paths is removed. Use node_modules folders, or the NODE_PATH environment variable instead.
at Function. (module.js:360:11)
at Object.eval (/Users/steve/local/lib/node_modules/coffee-script/lib/coffee-script.js:97:32)
at Interface. (/Users/steve/local/lib/node_modules/coffee-script/lib/repl.js:44:34)
at Interface.emit (events.js:67:17)
at Interface._onLine (readline.js:153:10)
at Interface._line (readline.js:408:8)
at Interface._ttyWrite (readline.js:585:14)
at ReadStream. (readline.js:73:12)
at ReadStream.emit (events.js:88:20)
at ReadStream._emitKey (tty_posix.js:306:10)


There is still an addition to the require.paths array somewhere in your application swparr.

You can try my fork of Less, which I have not merged or updated since the patch. I'm using it in production and development without a problem (with CoffeeScript):


Are there plans to fix this issue soon? Node v0.6.0 is out, and as a stable branch we'd very much like to move to it, but this issue is preventing us.

guileen commented Nov 7, 2011

Why this issue pending so long time? Isn't it easy to fix? what's the problem? just replace those requires to require('../blabla'), why pending so long time?

olostan commented Nov 7, 2011

Did anybody tried this pull request #377 with lastest releases of node?

ryall commented Nov 8, 2011

Just tried it, works beautifully.

Easy fix for now is to:

led commented Nov 9, 2011

Just got bitten by this problem. Thanks to all, particularly kixxauth for sorting out a fix.

kixxauth commented Nov 9, 2011

Perhaps the time is coming where the need is great enough to build a fully Node.js compatible Less rendering program as a fork and publish it properly in the npm repository? The require.paths problem, as well as a few others, including proper error trapping and reporting, do not seem to be getting pulled into the canonical Less.js repository.


i'll try to remain constructive with this comment.

@kixxauth agreed - but forking a project can be quite divisive and so i wouldn't take it lightly.

its disheartening to see 253 open issues and 38 open pull requests. a number of people have reported problems and offered solutions with little or no response. the same problems get reported multiple times and we also see multiple pull requests opened around the same issue. i know that i personally don't have the time to maintain a project like this and so i understand if its difficult for @cloudhead to take the time to address all of these bugs and pull requests - i could never manage to do this myself - but we need to be able to move the code forward.

as someone who is using this project, i need to know that if i find bugs and try to offer solutions, that those bugs can be addressed and changes can be incorporated into the canonical repository in a timely manner. it seems that there is enough of a community wanting to help improve the code but the bottle neck is that we all depend on a single person who seems to be largely inactive on this project (for possibly very good reasons). i really appreciate how this project makes my life easier and so i don't mean to bash @cloudhead.

i don't have the time to commit to maintaining a fork but if someone wants to take on that responsibility, i would be glad to continue to report bugs and offer pull requests. i would be even happier if we didn't need to fork though.

olostan commented Nov 9, 2011

I still have a hope that this pull request would be incorporated. Because unlike many other bugs, it make LessJS absolutely not usable (without doing manual fixes).

So lets use fork until pull request would be accepted.


It seems like the solution might just be for @cloudhead to add some others as collaborators so that there are more eyes (with push privileges) on these issues.

Evanlec commented Nov 10, 2011

@amccollum agreed. @cloudhead please add a few other active developers (volunteers) as collaborators for this repository. And thus the issue will be resolved and development can move forrward....

geddski commented Nov 10, 2011

What's the hold up?


Fixed. Please confirm it works, and I'll push 1.1.5. I'm travelling right now, so it's hard to keep up with things.

I'd like to find someone who I can trust enough to have commit access, but it's hard.

For example, it's pretty rare that I can just merge a non-trivial pull-request without modification. Eventually though, I hope to find one or more people to help, because I really don't have time to go over all the pull-requests, code-review them and test them, unless it is a critical issue like this one.


Also, feel free to send me a tweet if critical issues like this one come up. My notification inbox is unmanageable, the only way I find out about these things is if I run into it myself, by luck, or if someone tells me.


Thanks Alexis.

Maybe you could pick out 2 or 3 of the contributors to be "lieutenants" like in the Linux Kernel? They would not get push access, but could be trusted to do a proper code review and create patches which will require less work for you to integrate. Later on, maybe you could then give push privileges to one or two of these people familiar with the project and lessen the burden on yourself.

You don't know me from Adam, but I'd be willing to help review.

-- Kris

Evanlec commented Nov 13, 2011

@kixxauth excellent suggestion, I agree you should get at least one other person, preferably two to help you out with this, as we know nodejs development moves at a very rapid pace.
Not to mention I think less.js is the best of the CSS "Frameworks" ;)

Evanlec commented Nov 13, 2011

Hmm, is it just me, or is bin/lessc still broken? looks like it still has the require.paths in it even on latest git pull...


Hm no indeed, forgot to patch the scripts. Should be good now!

svnlto commented Dec 10, 2011

I'm on 0.6.5 and hitting the same issue.


Same here

svnlto commented Dec 12, 2011

ok in my case less was referring to an old version I had installed global. gotta check for that.

@cloudhead cloudhead closed this Dec 17, 2011
royki commented Mar 17, 2012

I m facing the following problem while try to execute node PaintServer.js in windows

throw e;//process.nextTick errror. or 'error' event on first tick
Error: Cannot find module 'nowUtil.js'

how to get out from this....????


Please go to Eclipse Right Click on Project -> Resources -> Linked Resource -> Path Variables

add : Name : NODE_PATH
Location : /path to node-v0.10.4/node_modules

Njoy :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment