npm install bluebird doesn't install module - npm

I am attempting to use bluebird in a node application. I have tried adding bluebird to my package.json, as well as installing via npm install bluebird.
My package.json dependencies:
"dependencies": {
"express": "visionmedia/express",
"mocha": "visionmedia/mocha",
"bluebird": "petkaantonov/bluebird",
"waitjs": "elving/wait"
}
Regardless of what method I try, it doesn't look like the module is actually being installed. After I run the install; in node_modules\bluebird there are only 4 files:
changelog.md
LICENSE
package.json
READEME.md
As you can see, there is no code pulled down which would actually comprise the module. The package.json for bluebird does not have a dependencies section, so I am not sure if maybe the package.json file for the module is incorrect?
I've pasted the package.json contents on pastebin for easier viewing.
I'm pretty stumped why this is not installing correctly.
npm version: 2.11.3.
node version: v0.12.7.
Thanks for any help.

The dependencies section of the packages.json should have version numbers as the module values, not git repos.
If you are having this issue, remove your dependcies section from package.json and then install each module using npm install {module name} -save.
My package.json ended up looking like:
"dependencies": {
"bluebird": "^2.9.34",
"express": "^4.13.1",
"mocha": "^2.2.5",
"waitjs": "^0.2.0"
}
Thanks to untogethered on reddit for the answer.

First thing to always try with module install problems is:
npm cache clean
Then try and install again, also remember to remove the bad install at node_modules/bluebird

Related

Is there any way to update a devDependency version of a nested dependency?

In a react-native project, there is mocha (9.2.0) as a devDependency like the following -
react-native-svg -
"dependencies": {
"css-select": "^5.1.0",
"css-tree": "^1.1.3"
}
css-tree -
"devDependencies": {
...
"mocha": "9.2.0",
...
}
When I perform the app bundle, I found the mocha is there.
Now I want to upgrade the mocha version to 10.1.0. I can do that by modifying the package-lock.json. But is it possible to do the same without modifying the package-lock.json by using the npm override or resolution or something similar to that?
you can use patch-package https://github.com/ds300/patch-package, modify dependencies in node_modules and then patch it with npx patch-package css-tree or what package do you want to fix.
You can try this command but it will still update your package.json ultimately
npm install mocha#10.1.0 --save --only=dev

NPM 7/8 is not installing peer dependencies

I'm trying to build a repository/package for my personal ESLint config files. I have all of my configuration files built the way I would like, and now I am trying to install this package to test it.
In this scenario, I have two packages:
#me/eslint-config is the package containing my ESLint config files.
test-package is the package on/in which I am trying to install #me/eslint-config.
When I try to install the #me/eslint-config package, peer dependencies are not installed, nor are they even mentioned during the installation.
Both packages currently only reside locally on my machine, side-by-side, in the same directory:
<parent_dir>:
- eslint-config
- package.json
- ...
- test-package
- package.json
- ...
The package.json file for #me/eslint-config looks as follows:
{
...
"dependencies": {
"#typescript-eslint/parser": "5.29.0"
},
"peerDependencies": {
"eslint": "8.18.0",
"eslint-plugin-import": "2.26.0",
"eslint-plugin-jsdoc": "39.3.3",
"eslint-plugin-prefer-arrow": "1.2.3",
"#typescript-eslint/eslint-plugin": "5.29.0"
}
...
}
I am installing this package in test-package as follows:
$> cd /path/to/test-package
$> npm i ../eslint-config --save-dev
NPM properly installs all other dependencies, including the #me/eslint-config package itself, but does not install the peerDependencies of #me/eslint-config.
This is using NPM v8.1.0.
This article seems to suggest that NPM >7 installs peer dependencies automatically. This is obviously not working for me.
Things I have already tried that have not fixed the problem:
Deleting node_modules/ and package-lock.json from test-package and reinstalling everything.
Pinning all peerDependencies versions in #me/eslint-config.
Adding all peerDependencies in #me/eslint-config as both dependencies and peerDependencies in #me/eslint-config.
tl;dr NPM isn't installing peerDependencies
I had the same error on former version of npm and as you mention, npm ^8 now install peer dependencies.
But here could be ways of fining your problem
1 : estlint is a devDependencies (A guess)
eslint should be devDependencies and not a peerDependencies.
Maybe npm doesn't accept you to install it then.
I search a bit but couldn't find any real thread discussing about this
That said, I wouldn't install it as dependencies since it will be pushed to your production build, what, I think, you do not want.
2 : Being up to date
Try it with the latest version of npm
download the latest version of npm : npm install -g npm#latest
Delet node_modules/ and package-lock.json from test-package and reinstall everything. as you did already
2 : allowJs
If eslint is an js package & you see it being installed in the node_modules folder.
Inside the tsconfig.json file, under the compilerOptions add allowJs: true and set strict: false
"compilerOptions": {
"allowJs": true,
"strict": false,
Close all your instance of vs-code
Restart & retry (No need to remove the package-lock or so)

npm prune removes dependency module

In my package.json file I have:
"dependencies": {
"#aws/dynamodb-data-mapper": "^0.7.3",
"#aws/dynamodb-data-mapper-annotations": "^0.7.3",
"#my-company/common": "file:../common",
...
}
#my-company/common specifies a local module which is installed by yarn.
However, when I run npm prune, this module is pruned.
I thought that including it in the package.json dependencies object would stop it from being pruned? Did I miss something?
For those who come across this, I discovered that running npm ls showed that there was an error with the common module.
Installing with NPM instead of Yarn fixed the issue.
Installing with Yarn did create the package within node_modules, however there was obviously an error somewhere which I couldn't uncover.

npm install always goes for the local package instead of a remote

I have created project my-npm-lib and published it with npm.
Now I have an another project where I want to do:
npm install my-npm-lib --save
But if I do so, it always add to dependencies:
"dependencies": {
"my-npm-lib": "file:..\\my-npm-lib"
}
This is actually correct because I have the my-npm-lib project located there on the device where I do this.
But this is something I don't want to. Later in my new project I use the webpack and I need to do:
include: [
path.resolve(__dirname, "src"),
path.resolve(__dirname, "node_modules/my-npm-lib")
],
which
is impossible now because the module is not located in node_modules,
doesn't allow me to share the new project correctly with other associates, because there is a wrong path in the package.json file.
So far I have tried to rewrite the package.json manually with
"dependencies": {
"my-npm-lib": "^1.0.0"
}
and then use npm install, but it didn't install this particular module.
PS: Im quite sure my-npm-lib is working with npm, because it is working on other device. It seems there is a problem only with the device where the my-npm-lib is being developed.
I have found the solution,
be sure that package.json dependencies has a correct structure,
use npm install my-npm-lib --save,
then rewrite the "file:..\\my-npm-lib" to "^1.0.0",
delete the package-lock.json!, (it was the missing piece)
cast npm install again.

npm install clear the react-native in node_modules

I face with a problem when try to use npm install to install redux to my react-native project. Any time I do run npm install redux --save the react-native directory inside node_modules will be cleared.
Then I use rm -rf node_modules && npm install the all react-native package does not install inside node_modules so I must re-create project.
I also try to copy & past react-redux and redux in node_modules from another project to my current react-native project. But it can't success, the error lead me to the issue on github. I followed this help and it also fail.
Some other information:
➜ npm: 5.0.3
➜ react-native-cli: 2.0.1
➜ react-native: 0.45.0
➜ package.json
{
"name": "MyProjectNAME",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"react": "16.0.0-alpha.12",
"react-native": "0.45.0",
"react-redux": "^5.0.5",
"redux": "^3.6.0"
},
"devDependencies": {
"babel-cli": "^6.24.1",
"babel-jest": "20.0.3",
"babel-preset-es2015": "^6.24.1",
"babel-preset-es2017": "^6.24.1",
"babel-preset-react-native": "1.9.2",
"jest": "20.0.4",
"react-test-renderer": "16.0.0-alpha.12"
},
"jest": {
"preset": "react-native"
}
}
Any suggest is appreciated. Thank you
Glad you have solved this issue using a workaround way but please allow me to explain why react-native module was removed when you ran npm install redux --save.
Solution:
Move the package-lock.json out of the project folder (Don't delete it yet because you will need to inspect it later on)
Run rm -rf node_modules && npm install
Check the /node_modules and react-native should be there now
Run npm install redux (npm v5 will --save by default) to install redux without having existing modules get removed
What is package-lock.json?
There are a bunch of changes for npm v5 which you can read it here. One of them is generating package-lock.json (lockfile) whenever npm modifies /node_modules or package.json.
With package-lock.json, anyone who runs npm install (v5) will get the exact same node_modules tree that you were developing on. So, you would have to commit this file too.
Why react-native module and others were removed after running npm install somePackageName even they are defined in the package.json?
The removal happened because of your existing node modules were installed prior to npm v5. If you use npm v5 to install a module (e.g. npm install redux), you will notice three things:
package-lock.json will be generated (or updated if exists). Redux and its dependencies are saved into it.
The redux's package.json is different than node modules that were installed prior to npm v5 (some extra fields prefix with _ e.g. _from, _requiredBy, _resolved etc.).
Finally, any module installed prior to v5 will be removed which I guess due to the missing extra fields in its package.json AND does not exist in the newly generated package-lock.json.
So, running rm -rf node_modules && npm install again will not solve the issue because of the package-lock.json file (Remember only redux and its dependencies were saved to the file? You can check the old package-lock.json)
Hope this might help someone else.
Finally, I solved this problem by 2 steps:
1) Create a reactjs project and install redux
2) Copy all content of node_modules in step 1 and paste to my current react-native project.
Reload app. Everything works well.
It gets removed if you create app using yarn. If you have created the app using yarn please run yarn add react-redux instead of npm install react-redux