-
-
Notifications
You must be signed in to change notification settings - Fork 184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
npx resolve
errors
#315
Comments
I'm a bit confused, can you clarify how you're getting this error? |
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 and inside I do run |
aha, thanks :-) so, the bug is that it doesn't work with npx. |
resolve
must be run directly as an executablenpx resolve
errors
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) |
This comment was marked as outdated.
This comment was marked as outdated.
There'll be no need for that workaround; i'll have a release cut momentarily. |
v1.22.5 - [Fix] fix `npx resolve` by handling symlinks (#315) - [Dev Deps] update `array.prototype.map`
v1.22.5 is published. |
it works. Thanks |
@ljharb just for my understanding - is this limitation to have correct argv and have no errors on processing params? |
And to ensure it can’t be required/imported. |
function isEntryPoint() {
return require.main === module;
} might be more relyable solution for this |
|
Can you link some information about it? https://nodejs.org/api/modules.html#accessing-the-main-module |
More than that https://nodejs.org/api/deprecations.html#dep0138-processmainmodule DEP0138: |
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.
@ljharb FYI^^ |
I'm not going to use |
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 |
Changes since v2.0.0-next.4: - [Fix] fix `npx resolve` by handling symlinks (#315) - [Fix] allow `npx resolve` to work (#316) - [Tests] rename innocent test project to avoid flawed security scanners - [Tests] avoid publishing "malformed package.json" test to avoid flawed security scanners Including all changes in v1.20.2 - v1.22.8 v1.22.8 - [Tests] rename innocent test project to avoid flawed security scanners v1.22.7 - [Tests] avoid publishing "malformed package.json" test to avoid flawed security scanners v1.22.6 - [Fix] allow `npx resolve` to work (#316) - [actions] use reusable rebase action v1.22.5 - [Fix] fix `npx resolve` by handling symlinks (#315) - [Dev Deps] update `array.prototype.map` v1.22.4 - Revert "[Refactor] deprecated `lib/core.js` now uses data from `is-core-module` also" - [Deps] update `is-core-module` - [Dev Deps] update `@ljharb/eslint-config`, `aud`, `semver`, `tape` - [meta] commit published core.json data v1.22.3 - [Refactor] deprecated `lib/core.js` now uses data from `is-core-module` also - [Deps] update `is-core-module` v1.22.2 - [Refactor] deprecated `lib/core.js` now uses `is-core-module` - [meta] cp core.json on prepack instead of prepublishOnly - [Deps] update `is-core-module` - [Dev Deps] update `@ljharb/eslint-config`, `aud`, `tape`, `array.prototype.map`
I have the error, so I added some debug info upfront:
that gives me:
I failed to follow the logic in this place
npm_lifecycle_script
can have space at the end?Hope you can help / clarify this moment =)
Thanks in advance
The text was updated successfully, but these errors were encountered: