Develop a npm package based on old version code - javascript

A npm package has old versions like 1.0.3 and new versions like 2.1.2, I found there is a bug at version 1.0.3, so I need to fix it and publish a new version 1.0.4, so I need to get the code of 1.0.3, but I found that there is no tag at the git repository, so how to do with this?

Related

Is there a way to downgrade my npm version to match the node-hid library?

Using node.js, I wanted to create a kiosk application with a RFID Reader attached to the kiosk. In order to access my RFID Reader, I installed the node-hid library (https://github.com/node-hid/node-hid). However, when I tried to run the application, an error occured, says:
Uncaught Exception
Error: The module 'D:\Projects\Electron\SelfService\node_modules\node-hid...\build\HID.node' was compiled against a different Node.js version using NODE_MODULE_VERSION 72. This version of Node.js required NODE_MODULE_VERSION 73.
I already updated the library and the node.js version to the latest update, but since the library is kinda old, it doesn't get any more update.
I tried to downgrade the node version, however there aren't any helpful tutorial I can find out there. I know there are many tutorial that explained how to install the older version of node, but I can't simply know what version of node I need from the error message displayed above.
I need to get the device readable by the application. If somehow, it's impossible to use the node-hid library, what is the latest library you recommended to access the RFID Reader from the application?
Note: I'm familiar with web development, including Javascript language, but Node.js is a new experience for me. I'll try my best to provide informations regarding my project, but if there are some mistakes with how I described my problem or if I have some difficulties in understanding your answers, please bear with me.
EDIT: I forgot to mention I'm on Windows 10, the node version I installed is 10.16.3
First Try this command -
Uninstall the electron first then try below command
sudo npm install --save-dev electron#4.0.0
sudo npm i --save-dev electron-releases#4.0.0
And also try to update chrome
Above is solution be sure minimum using Linux 16.04 with x64 processor and for npm version change see below
For NPM Version Downgrade of Linux/Ubuntu
sudo npm install -g npm#version
example-
sudo npm install -g npm#6.9
For Windows - start command prompt administrator
npm install -g npm#version
example-
npm install -g npm#6.9
You can uninstall the current node and then re-install the desired node version.
But the best practice will be installing node.js using the nvm aka node version manager.
Using nvm you can easily switch between different node version as well as different npm version.
Here's a quick start for installing node using nvm in both
windows, linux and unix platform.
NVM Official doc for unix and linux.
NVM alternative for windows

Can you get latest Beta build automatically though package.json and npm

We have a project that has a dependency that always needs to be the latest beta build from an npm library. Unfortunately, there are -dev builds in there as well.
For example, there could be the following versions in the "x-library".
"1.2.3-dev.294 // published today
"1.2.3-beta.123" // <--- the one we want published yesterday
"1.2.3-dev.293" // published a week ago
"1.2.3-beta.122" // published a month ago
Is it possible to get the latest 'beta' build automatically in a package.json like so:
devDependencies: {
...
"x-library": "latest-beta" // just for clarity
}
I don't think this functionality is available through npm. There's not even the possibility of using regex to define your dependency version currently.
You could cobble together a solution yourself. Make a bash script update-and-install.sh using these pieces:
get JSON with all available versions
npm show my-package versions --json
filter the JSON to get beta versions only
use the package semver-parser and its method compareSemVer to sort for the latest of those betas
use sed to edit your package.json to set the dependency to the desired version
run npm install
Don't know if that's helpful, but that's what I would try if this were a project requirement. Good luck!

Publish development version with semantic-release

I am using semantic-release with travis CI to automatically publish my package. I have two question:
My version has automatically been upgraded to v1.0.0. I want it to be something like v1.0.0-development. How can I do that?
Why my github's package.json's version not same as what has been published to npm?
My version has automatically been upgraded to v1.0.0. I want it to be something like v1.0.0-development. How can I do that?
You can't because v1.0.0-development is not a valid semantic version. Once https://github.com/semantic-release/semantic-release/issues/563 is released you will be able to use pre-release version (like v1.0.0-development.1).
Why my github's package.json's version not same as what has been published to npm?
See the first entry in the FAQ: https://semantic-release.gitbook.io/semantic-release/support/faq#why-is-the-package-jsons-version-not-updated-in-my-repository

Bower not downloading angular-payments with response - No versions found in git:

Why can't I get this directly through bower install? I'm trying to follow a combination of https://www.airpair.com/javascript/integrating-stripe-into-angular-app and https://github.com/laurihy/angular-payments but so far it's not going smoothly in regard to installing angular-payments. What am I missing? I've tried different versions of:
bower install --save angular-payments#9643191f2359e18d543c4abf1581f91f6729445f
which is the latest hash. But I also tried it without the hash and also by declaring the latest version, 0.1.1.

Using specific version of npm shrinkwrap

I am deploying my node.js app to Appfog but since their install script cannot parse npm-shrinkwrap.json the whole deploy process fails.
An example dependency in shrinkwrap.json today looks like this
"async": {
"version": "0.2.10",
"from": "async#0.2.10", <--- This line breaks install script at appfog
"resolved": "https://registry.npmjs.org/async/-/async-0.2.10.tgz"
},
I went through the whole shrinkwrap file and removed the "from" part from each dependency declaration and i managed to upload my application, and it works.
So my question is , how do i use an older version of npm shrinkwrap so i can get the version of shrinkwrap.json that i need?
Appfog support told me i need to use version 1.1.21 but i have not succeeded in installing it.
Please ask if some info is missing.
if you just want to use an older version of npm, you can install it via npm (i know that sounds strange, but its possible)
npm install npm#1.1.21
edit: so you try to install a version of npm which does not exist. just run
npm view npm
and take a look at the property version, to see which versions you could install via npm.
you will see that 1.1.21 does not exist in the registry, which means that you should try to install it via github (see answer by #sakai).
but then you see the next problem. you are using node#0.10.26, and npm 1.1.21 is probably not compatible with node#0.10.x.
so i for myself see basically 2 possible solutions:
Solution 1:
use n (or maybe nvm for switching node-versions back and forth. you could try to install a node#0.8.x version and try to install npm#1.1.21 there, and when done with shrinkwrapping switch back to your current node version.
Solution 2
you could setup some kind of grunt/gulp-task (i hope you use one of them) to run grunt/gulp shrinkwrap, which generates your shrinkwrap.json (via npm shrinkwrap) and when done cleans up your shrinkwrap.json
Try this:
npm install https://github.com/npm/npm/archive/v1.1.21.tar.gz
node ./node_modules/npm/bin/npm-cli.js shrinkwrap
Another—possibly simpler—solution is to just include node_modules into your repo.
Related: Should I check in node_modules to git when creating a node.js app on Heroku?

Categories