I am trying to install an sdk from https://github.com/niftylettuce/flightgear-saitek-pro-flight-switch-panel-hid-controller
the package.json looks as follows:
{
"name": "saitek",
"version": "0.0.2",
"main": "app.js",
"author": "Nick Baugh <niftylettuce#gmail.com>",
"license": "MIT",
"bin": {
"saitek": "./app.js"
},
"dependencies": {
"chalk": "^0.4.0",
"node-hid": "^0.5.4",
"underscore": "^1.6.0"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"description": ""
}
It clearly states it needs node-hid#0.5.4
When I check in my terminal (npm show node-hid version), it returns 0.7.3
As soon as I give the command:
npm install saitek -g
It starts with:
node-hid#0.3.2 install /usr/local/lib/node_modules/saitek/node_modules/node-hid
Clearly not the version I want. Especially as it gives all kinds of errors, which breaks the install.
I am on a MacBook Pro with Sierra as operating system.
The version of saitek on GitHub is more up-to-date; it has the node-hid dependency 0.5. If you install a package, npm will install the declared dependencies for that package. The last version of saitek released on npm is 4 years old and has an older node-hid dependency:
npm view saitek dependencies
{ ... 'node-hid': '^0.3.1' ...
It's up to the owner of the saitek package to publish a new version. You might try contacting them or getting in touch with npm support: https://docs.npmjs.com/misc/disputes
In the meantime you can install the package directly from GitHub since it has an updated package.json:
npm install -g https://github.com/niftylettuce/flightgear-saitek-pro-flight-switch-panel-hid-controller
This doesn't seem to work with node 10, but it does work with node 9 and 6 at least.
It's possible that npm install -g saitek will work with an even older version of node. It didn't work for 6 for me though.
Related
I'm using latest version of react-scripts npm package i.e. 4.0.3 in my react project and it has a vulnerabilities with one of his dependency package called browserslist, I was trying to resolve this vulnerability by adding this package under the resolutions section in my package.json file. I tried to override the package version with the help of preinstall command npx npm-force-resolutions and it will install the version we specified under the resolutions.
My package.json file will be
{
"name": "test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "react-scripts start",
"preinstall": "npx npm-force-resolutions",
"build": "react-scripts build"
},
"author": "",
"license": "ISC",
"dependencies": {
"react-scripts": "^4.0.3"
},
"resolutions": {
"browserslist": "4.16.6"
}
}
When I run the npm install the preinstall script will run and it will installing the browserslist package version after that I tried to check the list available vulnerabilities with npm audit command and I got 0 vulnerabilities.
Refer https://i.stack.imgur.com/cp1Sf.png to install command view.
Refer https://i.stack.imgur.com/8dLJz.png to audit command view
After that I tried to run the npm run build command and it will took build script from my package.json file. The build is failing with following error.
Refer https://i.stack.imgur.com/Lt3OE.png to build command view
I did lot of research on this from past 2 weeks but no luck at all. I'm definitely missing something after this. It would be great if anyone can help me on this it will be really appreciate.
Run this in your terminal:
npm i browserslist
Delete your nodemodules folder and package.lock.json file and run npm install.
npm ls -g shows a ton a packages and i havent installed any of them except 1 or two.
enter image description here
the package.json in my home directory:
{
"name": "yash",
"version": "1.0.0",
"description": "",
"main": "index.js",
"dependencies": {},
"devDependencies": {},
"scripts": {
"test": "mocha"
},
"keywords": [],
"author": "",
"license": "ISC"
}
the node_modules folder in my home directory is empty.
so what are all these files?
The -g flag will show global packages. These are packages which are not included in your package.json but are instead either packaged with your installation or were installed with npm install -g.
If the global packages you install have their own dependencies, then you'll also see those child dependencies listed. For example, you can see you installed nodemon, so you'll also see chokidar in the list, since nodemon requires that package to work.
If you want to ignore the child dependencies and see only the packages you directly installed, you can use npm list -g --depth 0.
You can read more about global packages vs. local packages
Let's say we have this simple package.json
{
"name": "test",
"version": "1.0.0",
"description": "Testing",
"main": "index.js",
"scripts": {
"test": "mocha"
},
"keywords": [
"tests"
],
"author": "JJ",
"license": "ISC",
"devDependencies": {
"mocha": "^8.2.0"
}
}
Basically we're looking to install mocha as a dependency for development, obviously. We run
npm i -g mocha
It's installed, and then
which mocha
works.
However, this does not yield the same result:
npm i -g --only=dev .
Obviously, it's installing things someplace else which is not in the path, possibly. But how come it's different? Running with --verbose does not yield much more information on where exactly it's going to be located.
Anyway, what I'm looking for is is a consistent way of specifying these global requirements. It does not seem too clean to create a Docker image or whatever with lots of npm i -g xxx yyy zzz followed by npm i with a package.json (or package-lock.json) where those dependencies are already specified. Maybe there's another way I've missed?
When you install an npm package with the -g tag, you are installing the package globally on your machine, not in your project;
Only use the -g tag if you are going to run something specific on your machine that isn't required by the project; otherwise, just hit npm i and install it directly on the project directory.
If it's going to be a development dependency, install it with npm install --save-dev mocha
I'm currently trying to implement this tutorial:
https://www.typescriptlang.org/docs/handbook/react-&-webpack.html
I'm supposed to install react and react-dom and also webpack + typescript + awesome-typescript-loader + source-map-loader, and that's what I did. I also installed webpack-cli accordingly to instructions that I got from the command line.
I installed all of them locally (the react and react-dom as PROD and the rest as DEV dependencies).Currently I don't have any packages installed globally.
After this, that's my package.json file:
{
"name": "reactandwebpack-tutorial",
"version": "1.0.0",
"description": "",
"main": "webpack.config.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"awesome-typescript-loader": "^5.2.0",
"source-map-loader": "^0.2.3",
"typescript": "^2.7.2",
"webpack": "^4.16.4",
"webpack-cli": "^3.1.0"
},
"dependencies": {
"#types/react": "^16.4.7",
"#types/react-dom": "^16.0.6",
"react": "^16.4.2",
"react-dom": "^16.4.2"
}
}
At this point, when I run npm ls I get a bunch of errors, because of some optional dependency of webpack that apparently is missing (all the errors in the tree are inside webpack and below fsevents as following):
webpack#4.16.4
(...)watchpack#1.6.0
(...)chokidar#2.0.4
(...)fsevents#1.2.4 -> UNMET OPTIONAL DEPENDENCY
And everything below fsevents is also marked with UNMET DEPENDENCY
And when I run webpack command, I get a "webpack not recognized error".
Anyone can help? I've been trying to wrap my head around this for a while.
PS:
Npm -v 5.6.0
Node -v 8.11.3 //(that's what I get from the terminal,
//VSCode "About" tells me something different, I don't know why).
Using Visual Code
Version 1.24.0
Date 2018-06-06T17:35:40.560Z
Shell 1.7.12
Renderer 58.0.3029.110
Node 7.9.0
Architecture x64
The reason is because it was not linked to your env. When you install something globally, you have access to it everywhere, hence it works just by doing webpack. Since you installed everything locally, the binaries are located inside node_modules/.bin.
You have two options when you install something locallly.
Use npm scripts (npm run build, watch... whatever).
./node_modules/.bin/moduleName --flags
It is easier to create a npm script and add all the commands there.
SOLVED
Not sure the reason but it had something to do with the ./bin folder with the webpack-cli "ambient variable" not being available (I don't know it that would be the most accurate description).
When I try to run webpack, I get "not recognized error".
But when I run nodemodules\.bin\webpack-cli it works normally.
Everything is installed locally.
I can also run it with options, like nodemodules\.bin\webpack-cli --help
If you run "webpack", The CLI will find global webpack with is installed by (npm install webpack -g). To use webpack from local project. you should it to npm script.
package.json
{
"script": {
"start": "webpack"
}
}
By doing this, you can run npm start to run webpack.
I am trying to install packages in the package.json file. Unfortunately, when I run npm install, nothing happens (nothing is installed). I have used npm install on other repos and it works successfully.
Here is my path:
$PATH = /Users/me/.rbenv/shims:/Users/me/.rbenv/bin:/usr/local/share/npm/bin:/usr/local/bin:/Applications/Postgres.app/Contents/MacOS/bin:/usr/bin:/bin:/usr/sbin:/sbin
As you can see, npm/bin is in my bath and I believe this is correct.
Here are the instructions for this repo and where to run npm install (which I am doing)
go into "module"
run "npm install"
pair your laptop/pc with intelligent brick troubleshoot: http://www.ev-3.net/en/archives/97
run example.js: "node example.js"
see "example.js" for more details
When I run npm install in the module directory (that has the package.json) nothing installs.
Here is the package.json:
{
"name": "ev3-nodejs-bt",
"description": "Bt Api for lego ev3 robot",
"version": "0.0.4",
"private": false,
"dependencies": {
"serialport": "1.*"
},
"main": "Ev3.js",
"devDependencies": {"serialport": "1.*"},
"scripts": {
"test": "node Ev3.js"
},
"repository": {
"type": "git",
"url": "https://github.com/wenchaojiang/Ev3NodeJsBtAPI"
},
"keywords": [
"node.js",
"ev3",
"lego",
"robot",
"bluetooth"
],
"author": "Wenchao Jiang <psxwj#nottingham.ac.uk> (http://wenchaojames.wordpress.com/)",
"license": "MIT",
"bugs": {
"url": "https://github.com/wenchaojiang/Ev3NodeJsBtAPI/issues"
}
}
Do I have something set up wrong on my system? (I don't think I do based on my $PATH and successful installing packets in other node-js repos) Is this package.json file not valid?
npm install doesn't install (or echo) anything when all of the dependencies are satisfied. Ensure there's a serialport folder under node_modules.
If you want to reinstall everything, you just need to remove the node_modules folder:
rm -r node_modules
npm install
If you have an npm-shrinkwrap.json file, check it. The npm install command will only install the packages specified in that file.
According to the npm install docs:
If the package has a shrinkwrap file, the installation of dependencies will be driven by that.
I had the same problem with my project. And when I looked at my npm-shrinkwrap.json file, I saw dependencies: {}. So that's why it didn't install anything for me.