how to add jquery-slider to the dependency list in browserify? - browserify

Description : I have package.json and bower.json for handling dependencies in my current schema. In which file should I add the "jquery.slider (version 1.1.0)" and how to do it?.
Currently,I have added the dependency in bower.json like below
"dependencies": {
"jquery.slider": "^1.1.0"
}
I have also tried it added in package.json and also in both ,but the slider is not even getting displayed.
Can anybody help me on this?

You could install it with npm, so it would be added to your package.json automatically.
npm install --save jquery.slider
Note the --save option within the command. This will add the module to the dependencies.
Then, if someone will clone the project he can simply run
npm install
to install all dependencies defined in package.json, included jquery.slider, automatically.

Related

package-lock.json in npm workspaces

Given an npm workspace with the following structure
workspace
package.json
packages
package-a
package.json
package-b
package.json
When I run an install command in package-a this will generate a package-lock.json file in the root of the workspace but not in the package.json file itself.
Is there a way to also generate it in the packages?
I don't know if this solves your problem, but you can specifie the folder in which you would install with --prefix
npm install --prefix ./install/here
you can use the lerna tool to manage your workspace and install dependencies in each package. you can generate package-lock.json files in each package in your workspace.
The Original Tool for JavaScript Monorepos. Monorepo means a repository with multiple packages.
lerna.js.org
I hope this answer will show you the right direction.
In most cases, running npm install within that package directory should do the job. But as you said that this is creating a global package-lock.json. This might be because the package you are installing might be specifying the global path using the prefix field.
The "prefix" field, specifies the location where the package's dependencies should be installed.
So one thing you can do is to go to the package.json in package-a and then either remove the prefix field from the package.json file OR set its value as following :
{
"name": "my-package",
"version": "1.0.0",
"prefix": "./",
"dependencies": {
...
}
}
Now when you run npm install it should install the packages locally and make a local 'package-lock.json`.

npm pack with modified package.json content

I would like to create a npm package using npm pack or yarn pack with a customize package.json in the package.
In other terms, I would like to suppress devDependencies, change scripts from the initial package.json to the package.json included in the tgz tarball.
Is ther a simple way to do that ?
Thanks,
Pisamad

Bitbucket NPM private package not install dependencies

I have my own NPM package in bitbucket as private repository which I installed in my main project as following:
"devDependencies": {
"my-package": "git+ssh://git#bitbucket.org/{name}/my-package.git"
}
This works like a charm, but there's a problem with the package itself. It contains a package.json with its own dependencies, but my main NPM is not installing this, it does not seem to keep in consideration what my package's package.json contains.
E.g: I am now missing packages that my own packages requires.
What can I do to make NPM always install my package packages defined in package.json?
Structure wise:
MyApp
- package.json (I run npm install on this one)
- some other php files..
- node_modules
- my-package
- package.json <-- This contains dependencies, which are not installed
Solved it, problem was that we defined our packages in the devDependencies, which should be in the dependencies.

Package.json pasting a package name in bad?

What happens differently when you go into your package.json and paste a package name in and do npm i vs. doing it the real npm i package-name?
package.json:
"dep": 1.0.0
vs
npm i dep --save
We have a build error and learned can bypass it by pasting. I know it isn't kosher but I really want to know why and what consequences that causes?
npm install dep doesn't add the dependency to the package.json file.
You have to add --save or --save-dev to add it to the package.json file.
Besides that, npm install will always serve you the latest build (in most cases the version tagged as latest (see npm docs)), unless you specify a specific version.
If you want your lock file to update, you have to delete the file before running npm install to generate a lock file with the dependency included (for more info check out this GitHub issue)
In conclussion it shouldn't make much of a difference if you manually add the dependency to package.json file and install it with npm install, unless the latest version of your dependency is broken.

How to update package.json dependencies when linking from globally installed packages?

I organize my development projects installing globally all the npm packages I need with:
npm -g install [package]
Then I simlink individually the dependencies I need for each project with:
npm link [package]
This way, I have to update manually each package.json file to add the dependency, and when I upgrade the global node_modules I have to go and update all the package.json projects.
For this first issue I tried npm link [package] --save but it doesn't add the dependency to package.json and if I use npm install [package] --save it installs the package locally, thing I don't want.
Is there any way to be able to not have to configure package.json manually and be able to have an updated configuration of package.json from many different projects in a easier way?
Yes you can install npm-check-updates, you can find the install and guide here:
https://www.npmjs.com/package/npm-check-updates
when running 'ncu' on the command-line in your root-folder where your package.json is, it will list the packages that can be updated and by running 'ncu -u' on the command-line it updates all the packages for you.