Are not all npm packages available to install with jspm? How do I install them? - jspm

I'd like to use this npm package in my project (https://www.npmjs.com/package/d3.promise), but when I search
jspm install npm:d3.promise --save
I get back:
err Repo jspm:--save not found. Perhaps try jspm install npm:--save.
I don't understand why jspm can't find it when it's a perfectly valid npm package. How would I go about installing this?

Don't use --save, it's not npm, simply try:
jspm install npm:d3.promise

Related

npm install --save not installing the module

I am integrating firebase cloud functions with my app's workflow. I needed to install a package so I did npm install --save #sendgrid/mail. The installation was a success but I can't see the dependency either in node_modules folder or the package.json file. What do I do?
One way to add the package would be to do the reverse. Add #sendgrid/mail to your package.json with the version you want, and then run npm install.

Install packages locally with npm

I am new with Node and npm, and when I try to install packages locally, all of the dependencies for that specific package gets installed in the main nodule_modules folder.
It looks like this
LOCALLY
And if I install them globally it looks like this
GLOBALLY
I think I should mention the fact that the folder where I try to install locally is on Desktop.
If you need to install specific dependancies for a project you are working on then do it locally:
npm install <packagename>
If you need something that you can run from the commandline such as grunt or phantomjs (etc..) then install it globally:
npm install -g <packagename>

npm install whatever --save is not saving into my package.json?

I have been installing packages and just noticed that not many of my packages are in my package.json? I always do --save when I install. In fact I just installed about 10 dependencies and none saved.
Has anyone run into this before?
Try to do --save-dev when installing your npm package. It will save all the devDependencies that are used in development. --save just save the dependencies. May be there is no dependencies that are dependent on your project.
Have you run npm init before?
Try to run npm init then npm install xxxx --save

NPM install grunt#version - No repository field

I'm trying to install grunt since the grunt watch for example is not working, shows as error: grunt command not found. When I do npm install grunt#0.4.1 --save-dev this is what appears:
And does not let me install it. I tried doing another package.json, doing a clean npm install and still, no idea what's going on.
Can anyone help me please, how can I solve this problem?
It seems that you need to install the Grunt CLI globally:
npm install -g grunt-cli
With this in place you should be able to setup grunt for any new project.

How to install a previous exact version of a NPM package?

I used nvm to download node v0.4.10 and installed npm to work with that version of node.
I am trying to install express using
npm install express -g
and I get an error that express requires node version >= 0.5.0.
Well, this is odd, since I am following the directions for a node+express+mongodb tutorial here that used node v0.4.10, so I am assuming express is/was available to node v0.4.10. If my assumption is correct, how do I tell npm to fetch a version that would work with my setup?
If you have to install an older version of a package, just specify it
npm install <package>#<version>
For example: npm install express#3.0.0
You can also add the --save flag to that command to add it to your package.json dependencies, or --save --save-exact flags if you want that exact version specified in your package.json dependencies.
The install command is documented here: https://docs.npmjs.com/cli/install
If you're not sure what versions of a package are available, you can use:
npm view <package> versions
And npm view can be used for viewing other things about a package too. https://docs.npmjs.com/cli/view
It's quite easy. Just write this, for example:
npm install -g npm#4.6.1
Or:
npm install -g npm#latest // For the last stable version
npm install -g npm#next // For the most recent release
First remove old version, then run literally the following:
npm install express#3.X
or
npm install express#4.X
and for stable or recent
npm install -g npm#latest // For the last stable version
npm install -g npm#next // For the most recent release
In my opinion that is easiest and fastest way:
$ npm -v
4.2.0
$ npm install -g npm#latest-3
...
$ npm -v
3.10.10
you can update your npm package by using this command:
npm install <package_name>#<version_number>
example:
npm install yargs#12.0.2
You can use the following command to install a previous version of an npm package:
npm install packagename#version
I have a general way to solve this type of problems, which could be helpful too, especially when cloning repositories to run them locally, but requires a little more analysis of the versions.
With the package npm-check-updates I verify the versions of the packages (according to the package.json file) that are not declared in their latest available versions, as shown in the figure (https://www.npmjs.com/package/npm-check-updates):
With this information we can verify the update status of the different packages and make decisions as to which packages to upgrade / degrade and which ones do not.
Assuming that we decided to update all the packages as they are listed, we can use the ncu -u command which only modifies your package.json file. Run npm install to update your installed packages and package-lock.json.
Then, depending on the requirements of the repository, we can refine what is needed, installing the specific versions with
npm view <package> versions and npm install <package>#<version>
The easiest way I found: add package name with the version in package.json and then run npm install
"next-seo": "^5.4.0",
"next-themes": "^0.1.1",
"nextjs-progressbar": "^0.0.14",
If you have to install an older version of a package, just specify it
npm install #
For example: npm install express#3.0.0
You can also add the --save flag to that command to add it to your package.json dependencies, or --save --save-exact flags if you want that exact version specified in your package.json dependencies.
The install command is documented here: https://docs.npmjs.com/cli/install
If you're not sure what versions of a package are available, you can use:
npm view versions
And npm view can be used for viewing other things about a package too. https://docs.npmjs.com/cli/view
Use npm config set save-exact=true if you want to install the exact version

Resources