In #reactivex/rxjs package it is suggested that scoped package should be used:
npm install #reactivex/rxjs
And UMD module is available through npmcdn as
https://npmcdn.com/#reactivex/rxjs#5.0.0-beta.7/dist/global/Rx.umd.js
However, unscoped rxjs package has got published 5.x versions too but README also suggests
npm install #reactivex/rxjs
And UMD module is available as
https://npmcdn.com/rxjs#5.0.0-beta.7/bundles/Rx.umd.js
Both refer to git+ssh://git#github.com/ReactiveX/RxJS.git repository, but package contents look totally different.
Why do their trees differ so much? What is the practical difference between those two? Is there a reason why one of them should be favoured at this moment?
doubled check now and they appears to be the same file
$ wget https://npmcdn.com/rxjs#5.0.0-beta.7/bundles/Rx.umd.js -q -O rxjs
$ wget https://npmcdn.com/#reactivex/rxjs#5.0.0-beta.7/dist/global/Rx.umd.js -q -O reativx-rxjs
$ diff rxjs reativx-rxjs
$
Related
for example, when I need to install webpack, usually we are supposed to use "npm i -D webpack", but if I use "npm i webpack" instead, there is no difference in my final bundle file, why we need to specify '-D'?
I think there is no differences between them, why not just use npm i?
npm i -D
npm i
As per the docs, npm install -D means you are installing the package as a devDependency and not a regular dependency.
How is this different?
When your app is deployed and your server runs the npm install step, it will only install the packages that are in dependency and not those in devDependency. Hence, we usually install things like eslint, typescript and such as devDependency and not regular depedency.
Reference
https://docs.npmjs.com/cli/v6/commands/npm-install
While studying Socket.io I encountered this npm command:
npm install -E socket.io-client#4.4.0
What does the -E tag mean?
npm documentation explains:
`-E, --save-exact`: Saved dependencies will be configured with an
exact version rather than using npm's default semver range
operator.
https://docs.npmjs.com/cli/v6/commands/npm-install
What does the -S flag for npm mean? I see it referenced here but https://docs.npmjs.com/cli/install does not cover what the -S is.
npm i -S #types/google-apps-script
-S is shorthand for --save, and it adds the package you're installing to the dependencies in your package.json file (which can be created with npm init). However, --save or -S is totally unnecessary if you're using npm 5 or above since it's done by default.
The 'S' option is the Save option in npm. It adds the npm package to your dependencies for your project. It's the same as --save.
I am looking for the meaning of the flag --u as in "npm run test --u" but I don't know where all the flags are documented.
Here are the bottom are some shorthands, but besides "gangster" and other cool ones, I couldn't find --u
https://github.com/npm/npmconf/blob/master/config-defs.js#L405
"npm run test --u" ("--u") belongs to jest flag --updateSnapshot. If you run npm run test help or npm test help you will get all the flags of jest.
Inorder to get npm flags list or npm commands you can run this command npm -l
Here are the list of other npm flags that you might need:
-u or --update: Updates the packages installed in you current working directory
-g or --global: Installs the package globally rather than in your local working directory.
-v or --version: Displays the version of npm.
-h or --help: Displays help information for the npm command.
-l or --long: Shows extended information for the installed packages.
-j or --json: Outputs the npm registry data in json format.
-S or --save: Saves the package as a dependency in your package.json file. As of npm version 5, you might not need this anymore as packages will be saved by default into the package.json file
-D or --save-dev: Saves the package as a dev-dependency in the package.json file.
-O or --save-optional: Saves the package as an optional dependency in the package.json file.
-E or --save-exact: Saves the package at the exact version specified in the package.json file.
-P or --save-prod: Saves the package as a production dependency in the package.json file.
-B or --save-bundle: Saves the package as a bundled dependency in the package.json file.
I am installing some packages on NPM, sometimes I have to write -s and -g? What do they mean?
npm install -s socket.io
npm install -g xxxxxxx
npm -g <package> will install a package globally on your machine. Without the -g or --global flag, the package will be installed locally in the directory you were in when you ran the command.
npm -S <package> with an uppercase -S or --save will install the package and save it to your dependencies in your package.json, although I believe that is now the default behavior in current npm. I recommend reading the docs if you're unfamiliar with what's happening when you pass different options to npm.
#gmmetheny answered the question about the global -g flag, but -s appears to silence the output of the command (at least in npm v7.0.15).
In other words, including -s (or --silent) in your npm install command means that it will have no output (only a newline):
> npm install -s example-package1 example-package2
This may be useful for running the command in a script.
Running the command without the -s flag echoes information about what was installed, e.g.:
> npm install example-package1 example-package2
npm WARN deprecated some-pkg#1.2.3: this library is no longer supported
added 160 packages, and audited 160 packages in 6s
14 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
You can diff the resulting directories created after running each variant of the command and you can verify that the effects are the same.
As #Max mentioned, this option is NOT mentioned in the npm docs (at least not in any prevalent location where a user might find it after a reasonable amount of searching).