Giter Site home page Giter Site logo

Comments (2)

radcapitalist avatar radcapitalist commented on June 4, 2024 4

Maybe I can help. I think what @hendrul is saying is that if you follow the instructions provided in the readme, it doesn't work. When node.js sees "require.context", it complains "TypeError: require.context is not a function." At least, that is my experience.

I'm at Node.js version 10.15.1. I've tried placing this line in a couple places:

require('require-context/register');

(Does the above line belong in the .js file where you're trying to use require.context() or in a .js file that gets required in before the .js file where require.context() is used?)

Nothing I've tried has caused require.context() to not throw the above TypeError.

I added the second "require" from the readme:

var requireContext = require('require-context');

without seeing how it could help require.context() be found, and it didn't, so I changed the line of code calling require.context() to call requireContext() instead. Which eliminated the TypeError, but what does this solve, because webpack will be looking for require.context()?

Also, when I put this line in my startup file:

require('require-context/register');

I got strange errors like this one from other modules:

path.js:39
    throw new ERR_INVALID_ARG_TYPE('path', 'string', path);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type function
    at assertPath (path.js:39:11)
    at Object.isAbsolute (path.js:404:5)

With 6000 downloads a week, somebody is clearly getting value from this module, but for the life of me I can't figure it out.

Thanks,

Eric

from require-context.

wilsonlewis avatar wilsonlewis commented on June 4, 2024

I'm not sure what you are asking - can you give me an example of exactly what you are trying to do?

Thanks!

from require-context.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.