Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

304
Views
Can't import global package in Node even though NODE_PATH is set?

I'm trying to import a globally installed pkg located at /some/path. I have set NODE_PATH in ~/.bash_profile. I am able to do 'echo $NODE_PATH' and see my path in a terminal. However node 11.10.1 still isn't finding the pkg. From what I read here https://nodejs.org/docs/v0.4.2/api/modules.html#all_Together require.paths should be initialized from this env var. However if I log require.paths, it is not set, console.log(require.paths) is undefined. How can I fix this?

console.log(process.env.NODE_PATH)

var i = require('promised-io')

exact error msg: Uncaught Error: Cannot find module 'promised-io'

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Have had the same problem with node v16.14.0 as installed in Ubuntu 21.10. The environment variable $NODE_PATH seems to be ignored, and the global install path as used by npm (/usr/local/lib/node_modules) is not searched by node. For me I found two workarounds:

  • Add module.paths.push('/usr/local/lib/node_modules'); to the *.js

or if you don't want to patch other peoples tools but still want to provide global installed packets e.g. for multiple users of a build server, you can simply fix this with a symbolic link. Looking into Node.js v16.14.0 documentation - Loading from the global folders shows, that node still searches in $PREFIX/lib/node but no longer in $PREFIX/lib/node_modules. So we can solve this deviation between npm and node global default path by

  • sudo ln -sf /usr/local/lib/node_modules /usr/local/lib/node
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!