| Summary: | node can't find requires without NODE_PATH | ||
|---|---|---|---|
| Product: | [Fedora] Fedora | Reporter: | Fabian Deutsch <fabian.deutsch> |
| Component: | nodejs | Assignee: | T.C. Hollingsworth <tchollingsworth> |
| Status: | CLOSED WONTFIX | QA Contact: | Fedora Extras Quality Assurance <extras-qa> |
| Severity: | unspecified | Docs Contact: | |
| Priority: | unspecified | ||
| Version: | 19 | CC: | fdeutsch, jamielinux, mrunge, sgallagh, tchollingsworth, thrcka |
| Target Milestone: | --- | ||
| Target Release: | --- | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| Whiteboard: | |||
| Fixed In Version: | Doc Type: | Bug Fix | |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2013-09-10 23:01:41 UTC | Type: | Bug |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
|
Description
Fabian Deutsch
2013-09-10 18:51:17 UTC
This is by design. Node.js' global module search path is by default set only to './node_modules', to allow the developer to create separate directories with separate dependency chains, similar to how virtualenv works with Python. To use yum-installed dependencies, just `npm link` them into your local project. To use dependencies we don't have yet, just `npm install` them. For instance: % mkdir test % cd test % cat >test.js <<EOF > var request = require('request') > request('https://badges.fedoraproject.org/user/fabiand/json', function (error, response, body) { > if (!error && response.statusCode == 200) { > var num = JSON.parse(body).assertions.length > console.log('You have ' + num + ' badges!') > } > }) > EOF % node test.js Error: Cannot find module 'request' % npm link request % node test.js You have 20 badges! For more information on the rationale behind this, see the npm FAQ: https://npmjs.org/doc/faq.html#I-installed-something-globally-but-I-can-t-require-it Thanks for this explanation. |