Giter Club home page Giter Club logo

Comments (17)

ljharb avatar ljharb commented on June 2, 2024 1

There'll be no need for that workaround; i'll have a release cut momentarily.

from resolve.

ljharb avatar ljharb commented on June 2, 2024 1

v1.22.5 is published.

from resolve.

ljharb avatar ljharb commented on June 2, 2024 1

And to ensure it can’t be required/imported.

from resolve.

ljharb avatar ljharb commented on June 2, 2024 1

require.main is deprecated and something that should never, ever have existed; i'm not going to use it.

from resolve.

vvscode avatar vvscode commented on June 2, 2024 1

I proposed once, this mention was just to inform you about the state of that API. Thanks for helping me with the issues

Good luck

from resolve.

ljharb avatar ljharb commented on June 2, 2024

I'm a bit confused, can you clarify how you're getting this error?

from resolve.

vvscode avatar vvscode commented on June 2, 2024

Sure =)

I just created new empty project

{
  "name": "resolve-demo",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "resolve": "^1.22.4"
  }
}

and installed dependencies with yarn

and inside I do run npx resolve

resolve-demo.zip

from resolve.

ljharb avatar ljharb commented on June 2, 2024

aha, thanks :-) so, the bug is that it doesn't work with npx.

from resolve.

vvscode avatar vvscode commented on June 2, 2024

I'm happy to help with the fix if you clarify the logic =)

shouldn't

String(process.env.npm_lifecycle_script).slice(0, 7) !== 'resolve'

or even

process.env.npm_lifecycle_script !== 'resolve'

solve the issue? (I didn't get that space at the end at all)

from resolve.

vvscode avatar vvscode commented on June 2, 2024

about workaround:

I added to package.json script

"scripts": {
       "resolve": "./node_modules/resolve/bin/resolve"
}

and run it with npm run resolve / yarn run resolve

just in case someone else faced the issue

from resolve.

vvscode avatar vvscode commented on June 2, 2024

it works. Thanks

from resolve.

vvscode avatar vvscode commented on June 2, 2024

@ljharb just for my understanding - is this limitation to have correct argv and have no errors on processing params?

from resolve.

vvscode avatar vvscode commented on June 2, 2024
function isEntryPoint() {
  return require.main === module;
}

might be more relyable solution for this

from resolve.

vvscode avatar vvscode commented on June 2, 2024

Can you link some information about it?
I checked node@20 docs and see it is there without any deprecation notes

https://nodejs.org/api/modules.html#accessing-the-main-module

from resolve.

vvscode avatar vvscode commented on June 2, 2024

More than that

https://nodejs.org/api/deprecations.html#dep0138-processmainmodule

DEP0138: process.mainModule#

History
Version Changes
v14.0.0 Documentation-only deprecation.

Type: Documentation-only

process.mainModule is a CommonJS-only feature while process global object is shared with non-CommonJS environment. Its use within ECMAScript modules is unsupported.

It is deprecated in favor of require.main, because it serves the same purpose and is only available on CommonJS environment.


DEP0138: process.mainModule[#](https://nodejs.org/api/deprecations.html#dep0138-processmainmodule) History Version Changes v14.0.0 Documentation-only deprecation.

Type: Documentation-only

process.mainModule is a CommonJS-only feature while process global object is shared with non-CommonJS environment. Its use within ECMAScript modules is unsupported.

It is deprecated in favor of require.main, because it serves the same purpose and is only available on CommonJS environment.

from resolve.

vvscode avatar vvscode commented on June 2, 2024

@ljharb FYI^^

from resolve.

ljharb avatar ljharb commented on June 2, 2024

I'm not going to use require.main ever, sorry. The current heuristic is my preferred approach.

from resolve.

Related Issues (20)

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.