I tend to compile my NodeJS installs from source. This typically means the version ends up being something like 17.0.0-pre. When I am trying to build the zwavejs2mqtt I get
To use this template, you must update following to modules:
node: 17.0.0-pre should be >= 12.0.0
How can I tell it that 17.0.0-pre is larger than 12?
Things I have tried:
Ensuring that NPM is completely up to date.
Related
System information
OS Platform and Distribution (e.g., Linux Ubuntu 16.04): macOS Ventura 13.2.1
TensorFlow.js installed from (npm or script link): npm
TensorFlow.js version: 4.2.0
Describe the problem
I had previously used the #tensorflow/tfjs-node library successfully with no issues. Now, however, I have changed environments and unfortunately I am running into issues. I don't have the original source code any more to compare to see what the difference is.
I am running under node v18.4.0, although I have tried v16.16.0 and v14.21.2 (using nvm on macOS).
The problem is now it seems the library wants all sorts of supporting modules, which are not installed:
aws-sdk
nock
mock-aws-s3
It will not build without these, so I npm i them and then it builds happily.
So first question: why might my environment now be needing these where it didn't need them before? What might be different? As I say, sadly I don't have the last environment around any more.
Having built this, I now receive the error:
Error: #package/learn package.json is not node-pre-gyp ready:
package.json must declare these properties:
binary
Although I could configure all this, I think it is the wrong thing to do, since I had it up and running previously without any of this. Is where are these issues now coming from?
Can I run the #tensorflow/tfjs-node without installing or needing those three dependencies? I can provide the other config if it is not apparent to someone who has had the same issue.
Source maps for other JS bundles are generated correctly, but vendor.HASH.js.map looks like this:
{"version":3,"mappings":"","names":[],"sources":[],"sourcesContent":[],"sourceRoot":"webpack:///","file":"vendor.HASH.js"}
There are not special errors during the build (except a few optimization bailouts due to CommonJS modules and some things about going over budgets).
What am I missing here?
Running on:
Angular CLI: 13.0.4
Node: 12.22.3
Package Manager: npm 6.14.13
OS: darwin x64
Dependencies are a mix of up-to-date libraries and some old packages, but most are updated to last year, as was available.
Config is pretty standard - but code migrated all over from Angular 6, in a series of upgrades over the years.
[I can provide outputs and more config, if needed - but SO formatter complains it makes the question "mostly code"...]
I have a previous version of node installed but after few days it gets automatically updated to the latest version. I do not want it to upgrade itself to a newer version.
You need to specify the exact node version in your package.json file.
A bit of background, from the NPM documentation:
It's important to communicate the extent of changes in a new release of code, because sometimes updates can break code that a package needs (called dependencies).Semantic versioning (semver) is a standard that was designed to solve this problem.
From your terminal, type node --version; you will get a number formatted as X.X.X
Open your package.json file and remove any ~ or ^ signs from the node version you want to use so that it won't update to any minor or batch changes.
enter npm install in your terminal again and you are done.
I'm have a small npm package which I'm writing in node 9 and using all the latest and greatest features like async/await. I'm also using babel which allows me to use ES6 module imports and exports
Babel also allows me to transpile the package to a target node version. I'm using the node release schedule to define which version of node the package will support and with the the target for the babel compilation. Currently node 4.x is still in maintenance lts stage, so I'm targeting it. Unfortunately this means almost every new feature in JavaScript I'm using gets transpiled.
What I'd like to do is to transpile the package to different targets (4.x, 6.x, 7.x, 8.x, and 9.x currently apply) and have npm choose the appropriate build of the package at install time based on the user's node version. If I'm not mistaken, I've seen apt-get do this with different versions of Ubuntu.
Is this possible with npm?
I'll bump an old thread here. A good option is to use two separate directories and choose the transpiled version depending on process.version.
I'll be trying to do this in scramjet and will be updating the thread along the way. My plan is to use an index.js file like this:
const ver = process.version.slice(1).split('.');
module.exports = require(+ver[0] > 8 && +ver[1] > 3 ? 'lib/index' : 'lib-6/index')
This should do for now, but since I also have some v10+ targeted code (especially DataStream.from(async function*() { ... }) which has some ifs in it I may want to extend it later and use a table.
What's important here is that the code above runs once (unless you clear require cache) and mostly in compile time so it has minimal influence over your module.
If I write a package I am certain requires Node 4 or higher, I don't want it to be installable with older versions.
I know about the package.json engines field, but that's just advisory (only causes a warning). And enginesStrict has been deprecated.
So what can I do?
One idea is to have a preinstall script that checks the Node version and errors if it's not high enough, preventing installation from continuing. Are there any problems with doing that? And is there a better way?
If you want a good experience, make your CLI entrypoint standard ES5 and CommonJS, detect the node version (process.version), and print a detailed and helpful message then exit non-zero. Keep in mind your module may get installed with some node version then the user futzes with nvm or their PATH or whatever and then runs your code under a different version. Thus I think failing nicely at run time is the most important thing. You can also choose to fail at install time if you like.