Comments (10)
If someone sends a PR to fix the docs, it will probably be accepted.
from node.
That doesn’t explain why the repl is started, though? I was surprised when that happened 😄
from node.
Reproductions:
$ node --run ''
Welcome to Node.js v22.5.0.
Type ".help" for more information.
>
$ node --run
node: --run requires an argument
$ node --run .
ExperimentalWarning: Task runner is an experimental feature and might change at any time
Missing script: "."
Available scripts are:
<...>
from node.
What about the first example from @RedYetiDev's last comment? What's the expected behavior? Why is there a REPL being started?
from node.
What about the first example from @RedYetiDev's last comment? What's the expected behavior? Why is there a REPL being started?
My reproductions were a bit out of order, but at the end of the issue, the author notes:
Giving the empty string to --run does not try to execute { "scripts": { "": "echo hi" } }. Neither does npm run '' though :)
from node.
That doesn’t explain why the repl is started, though? I was surprised when that happened 😄
FWIW my assumption is that it treats an empty string as if the flag wasn't there, so it performs the action as if that flag wasn't applied, in this case, trigging the REPL.
from node.
That's still quite odd and hardly seems desirable... I am wondering if it's intentional. @anonrig
from node.
Reproductions:
$ node --run '' Welcome to Node.js v22.5.0. Type ".help" for more information. >
That's odd behaviour. This is valid JSON:
{
"name": "nodejs_run_test",
"scripts": {
"hello": "echo hello",
"world": "echo world",
"": "echo !"
}
}
i.e. it's valid to have an empty string as a JSON key. So I would expect node --run ''
to behave the same as if a non-existent script was specified (unless of course a ""
script was defined as in the example above).
FWIW as reference, npm
can't run a ""
named script:
$ npm run-script ''
npm error valid event not provided to runScript
npm error A complete log of this run can be found in: /home/rlau/.npm/_logs/2024-07-22T12_39_38_822Z-debug-0.log
$
so Node.js could choose to do the same (but should probably be documented to do so, given that ""
is a valid JSON key).
from node.
Since npm compatibility clearly wasn't a priority, I think it's reasonable for Node.js to implement some reasonable behavior instead.
from node.
Since npm compatibility clearly wasn't a priority, I think it's reasonable for Node.js to implement some reasonable behavior instead.
Agreed, I'm just not sure the current behaviour is reasonable 🙂.
from node.
Related Issues (20)
- Assertion Failed in node::WorkerThreadsTaskRunner::DelayedTaskScheduler::Start() HOT 2
- Error: Cannot find module '..' HOT 1
- node:readline support reading non printable characters such as group separator
- Tracking issue: stabilization of test runner code coverage HOT 1
- yarn.lock file does not get created in nearly all the cases HOT 1
- http.server.close() closes idle connections in v20 and v21 HOT 3
- Node 22.5.0 breaks yarn install (1.22.22) HOT 2
- Tracking issue: Stabilizing network inspection in Node.js
- DNS Lookups Failing After Updating to Latest Node 20 and 18 for IBM i HOT 11
- readability/pointer is inaccurate HOT 1
- yarn install fail on node:latest HOT 2
- `parallel/test-assert-esm-cjs-message-verify` is flaky HOT 3
- For whatever reason, VS Code was not actually importing my user or system environment variables. I copied and pasted my system path and added in the necessary escape keys, restarted VS code, and was able to successfully use Node commands. So it seems this was actually more of a VS code issue, rather than a Node.js issue. HOT 1
- [regression] node-gyp: createConfigFile: Cannot assign to read only property 'cflags' of object '#<Object>' HOT 1
- ERR_INTERNAL_ASSERTION HOT 2
- flaky: test-child-process-cwd
- Import data: from data: should be allowed
- `--env-file` watch HOT 3
- Flaky: parallel.test-sqlite HOT 3
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 node.