Comments (17)
There'll be no need for that workaround; i'll have a release cut momentarily.
from resolve.
v1.22.5 is published.
from resolve.
And to ensure it can’t be required/imported.
from resolve.
require.main
is deprecated and something that should never, ever have existed; i'm not going to use it.
from resolve.
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.
I'm a bit confused, can you clarify how you're getting this error?
from resolve.
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
from resolve.
aha, thanks :-) so, the bug is that it doesn't work with npx.
from resolve.
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.
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.
it works. Thanks
from resolve.
@ljharb just for my understanding - is this limitation to have correct argv and have no errors on processing params?
from resolve.
function isEntryPoint() {
return require.main === module;
}
might be more relyable solution for this
from resolve.
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.
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.
@ljharb FYI^^
from resolve.
I'm not going to use require.main
ever, sorry. The current heuristic is my preferred approach.
from resolve.
Related Issues (20)
- Error "ENOENT: no such file or directory, open '../../is-core-module/core.json" HOT 20
- Question: NPM version 1.22.3 is published but 1.22.2 is marked as `latest` HOT 1
- WebpackError: TypeError: Unable to determine current node version
- Remove readFileSync HOT 1
- monorepo-symlink-test GHSA-2jcg-qqmg-46q6 Vulnerability HOT 9
- Resolve monorepo-symlink-test vulnerable package HOT 1
- The 'test' directory seems to contain the code of malicious package 'monorepo-symlink-test' HOT 1
- This package is being flagged as malware - false positive HOT 1
- [Security] Malicious code in `test/resolver/multirepo` HOT 19
- Critical Vulnerability due to Resolve Package -- monorepo-symlink-test HOT 2
- Critical vulnerability monorepo-symlink-test HOT 2
- monorepo-symlink-test HOT 5
- Used monorepo-symlink-test is malicious HOT 1
- Incorrect work on Linux (`Error: `resolve` must be run directly as an executable`)
- Critical Vulnerability reported on monorepo-symlink-test - False Negative HOT 1
- Critical Vulnerability with monorepo-symlink-test HOT 8
- monorepo-symlink-test security issue HOT 1
- Package includes test folder HOT 1
- Any reason to publish /test? HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from resolve.