Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7504211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T21:29:52+00:00 2026-05-29T21:29:52+00:00

Here’s the situation… So I’ve created a Node.js module that acts as an interface

  • 0

Here’s the situation… So I’ve created a Node.js module that acts as an interface to some Node.js template engines, Shift.js. That is included inside another Node.js module, Design.io (it’s specified Design.io’s package.json dependencies block). Design.io watches files for changes.

Then you build an app and require('design.io'). You also install, say, Less and Stylus into your project.

This way, when you save a .less or .styl file, a chain of methods are called:

  1. require("design.io") gets notified of the filesystem event. Design.io then calls
  2. require('shift').render(string, extension, callback). Shift.js then calls
  3. require(moduleFor(extension)) # require("less"). The string is compiled.

In my app (current working directory) I have installed less and stylus:

npm install less stylus

The problem I’m having is, in step 3 which is called from within the Shift.js module, I get errors like this:

Error: Cannot find module 'less'
    at Function._resolveFilename (module.js:334:11)
    at Function._load (module.js:279:25)
    at Module.require (module.js:357:17)
    at require (module.js:368:17)
    at Less.engine (/Users/viatropos/Documents/git/plugins/design.io/node_modules/shift/lib/shift/less.js:6:14)
    at Less.render (/Users/viatropos/Documents/git/plugins/design.io/node_modules/shift/lib/shift/less.js:18:21)
    at /Users/viatropos/Documents/git/plugins/design.io/node_modules/shift/lib/shift.js:69:23
    at /Users/viatropos/Documents/git/plugins/design.io/node_modules/async/lib/async.js:118:13
    at Object.forEachSeries (/Users/viatropos/Documents/git/plugins/design.io/node_modules/async/lib/async.js:134:9)
    at Object.render (/Users/viatropos/Documents/git/plugins/design.io/node_modules/shift/lib/shift.js:78:31)

My question is, why is this happening? I thought that you could dynamically require libraries from a module as long as they were installed somewhere… What am I missing?

The goal would be that libraries like Shift.js wouldn’t have to define every single dependency in package.json… For an “interface to the template engines” library, that would require too many dependencies that the app would probably never be using.

Thanks for the help, hope that was somewhat clear.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T21:29:58+00:00Added an answer on May 29, 2026 at 9:29 pm

    When you npm install foo, the foo module gets installed in a directory named node_modules in the current working directory.

    When you install this shift library, it only looks for modules to require within its own node_modules directory, or in one of the global directories require.resolve() searches.

    And that’s the simple solution to your problem:

    npm install -g less
    

    And then the library is globally visible to all Node.js code on your computer, rather than only being visible to code in the current working directory.

    Alternatively, if you only want shift to see it, then do something like this:

    npm install shift
    cd node_modules/shift
    npm install less
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's a basic regex technique that I've never managed to remember. Let's say I'm
Here is the issue I am having: I have a large query that needs
Here's my scenario - I have an SSIS job that depends on another prior
Here's a coding problem for those that like this kind of thing. Let's see
Here is the scenario: I'm writing an app that will watch for any changes
Here's some of my production code (I had to force line breaks): task =
Here's a query that works fine: SELECT rowid as msg_rowid, a, b, c FROM
Here is my code (Say we have a single button on the page that
Here's the flow that I am trying to achieve: 1) User uploads an audio
Here is my simplified data structure: Object1.h template <class T> class Object1 { private:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.