Coder Social home page Coder Social logo

Comments (3)

gajus avatar gajus commented on June 11, 2024

For documentation purposes:

curiosity:require-new gajus$ echo "require('./src')('./src')" | node

module.js:338
    throw err;
          ^
Error: Cannot find module '././src'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.require.resolve (module.js:388:19)
    at module.exports (/Users/gajus/Documents/dev/gajus/require-new/src/index.js:26:26)
    at [stdin]:1:17
    at Object.exports.runInThisContext (vm.js:54:17)
    at Object.<anonymous> ([stdin]-wrapper:6:22)
    at Module._compile (module.js:430:26)
    at node.js:567:27
    at doNTCallback0 (node.js:408:9)
    at process._tickCallback (node.js:337:13)

In the above case:

stackTrace.get()[1].getFileName() [stdin]

and

curiosity:require-new gajus$ node -e "require('./src')('./src')"

module.js:338
    throw err;
          ^
Error: Cannot find module '././src'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.require.resolve (module.js:388:19)
    at module.exports (/Users/gajus/Documents/dev/gajus/require-new/src/index.js:26:26)
    at [eval]:1:17
    at Object.exports.runInThisContext (vm.js:54:17)
    at Object.<anonymous> ([eval]-wrapper:6:22)
    at Module._compile (module.js:430:26)
    at node.js:567:27
    at doNTCallback0 (node.js:408:9)
    at process._tickCallback (node.js:337:13)

is:

stackTrace.get()[1].getFileName() [eval]

from require-new.

gajus avatar gajus commented on June 11, 2024

With this in mind, I have updated the code to use process.cwd() whenever "stdin" or "eval" is the stack origin.

from require-new.

gajus avatar gajus commented on June 11, 2024

@4368baed3c199c8284103a8842896d1d717e6720

from require-new.

Related Issues (2)

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.