NPM: skip dev dependencies when installing a package from Github - github

Is it possible to exclude dev dependencies when installing directly from GitHub?
Unfortunately the command
npm install --only=production my-repo#github:path-to/my-repo
doesn't seem to work, it only excludes dev dependencies specified in the current package.json file, not the ones specified in the package I am installing.

Related

How do I install a ionic plugin from the github repository?

The npm install docs explains how to install a dependency from the github source code rather than using the npm registry.
It works well when your project isn't scoped, so that if I wanna install express I can just execute:
npm install https://github.com/expressjs/express
and it works well.
In the ionic plugin case, though, this doesn't work correctly.
Ionic plugins are scoped, if I want to install the speech recognition plugin from the npm registry I can just execute:
npm install #ionic-native/speech-recognition
ThisĀ is the #ionic-native/speech-recognition npm page.
On the right sidebar there's the link to the corresponding github page, which is https://github.com/ionic-team/ionic-native.
If I try to execute:
npm i https://github.com/ionic-team/ionic-native/speech-recognition
It installs only the #ionic-native dependency rather than the plugin.
The same about:
npm i #ionic-native/speech-recognition#https://github.com/ionic-team/ionic-native
In both cases, the output is:
#ionic-native/speech-recognition#https://github.com/ionic-team/ionic-native
npm WARN #ionic-native/ionic-webview#5.28.0 requires a peer of
#ionic-native/core#^5.1.0 but none is installed. You must install peer
dependencies yourself. npm WARN uglifyjs-webpack-plugin#0.4.6 requires
a peer of webpack#^1.9 || ^2 || ^2.1.0-beta || ^2.2.0-rc || ^3.0.0 but
none is installed. You must install peer dependencies yourself.
ionic-native#5.28.0 updated 1 package and audited 1602 packages in 38.072s
Which only adds the following row in the package.json:
"ionic-native": "git+https://github.com/ionic-team/ionic-native.git"
If you are asking why I need it, it's because I need to install a forked repo.
How can I install a ionic plugin from the github repository?
Thank you
Most of the plugins used by the Ionic Framework where created for Cordova/Phonegap way before Ionic was published. These are the main technologies that Ionic was built uppon, so you can find the information where and how to download the plugins from the Cordova and Phonegap Github pages or official website.
Speech Recognition for Cordova

yarn - What does #npm mean?

I know that running yarn add package#1.2.3 would install package v1.2.3.
I recently encountered this syntax: yarn add package#npm. What does #npm do? Is it a special sign for yarn or is it specific to that package (material-ui)?
I encountered #npm as a solution to include two versions of material-ui by aliasing the next version: yarn add material-ui-next#npm:material-ui#next
No real surprises, it is a directive to install a specific package from npm.
yarn add {package1} installs the specified package from the npm registry by default.
yarn add {package1}#npm:{package2} installs package2 from the npm registry and assigns package1 as its alias.
It makes no difference if a package named package1 exists in the npm registry, it will only download the package you've specified with the #npm directive.
From your question, it seems like you've already got a handle on this one.

Ionic 1.x - from bower to npm

I used to install plugins in my ionic 1 project with bower. The new trend, especially with ionic 2, is to install packages with npm. Some core packages, such as ionic.cloud are not provided at all anymore with bower, even for ionic 1.x.
So I need to migrate some packages to npm. What is the recommended way to do so ?
My problem:
"npm install" seems to install packages in the "my_project/node_modules" folder, unlike bower which installs packages directly in my_project/www/lib/
As explained for instance in the installation guide of ionic.cloud this requires an additional step to copy the newly installed npm package in the lib folder with the command:
cp node_modules/#ionic/cloud/dist/bundle/ionic.cloud.min.js www/lib
However, when I update the package and run "npm update", this will update the node_modules folder, but not the lib folder. This is a problem as only the files from my lib folder are included in my index.html.
Running the cp-command after each npm update does not seem such an elegant solution. What is the recommended way to deal with this?
I think you can reverse this make the .bowerrc file create your packages inside the node_modules folder and use this path as default. Otherwise the node_modules is mandatory there is no way around creating it.
Even you can npm i --prefix ./bower_components/ <package> you still need to cp to folders up from bower_components folder

npm error while installing ionic dependencies

After cloning the project code from the Repository, I'm trying to install the npm to update the packages and plugins included. The command used is:
npm install
It worked well for previous clones. But now it displays the following error:
npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents#1.0.12
npm WARN appname# No repository field.
npm WARN appname# No license field.
When I tried to install fsevents using --verbose, it is said that the supported OS is Darwin. But it worked in the previous clone. Why not now?
If your a Windows user:
The fsevents warning isn't a problem. It's an optional dependency and isn't needed for this to work on Windows.
But the error still displaying, in order to fix this.
Open package.json and delete the gulp-watch dependecy
Manualy remove the folder (gulp-watch) from the node_modules fordel
Unload the Project and uploaded again
The error is gone!!!
There's a issue open to fix this in .net core , but this will work untill then.

`npm install <folder>` or `npm pack` does not install dependencies

I have an npm package that uses coffeescript source, which I want to precompile before pack or publish. However, my prepublish script depends on coffee-script as a devDependency, but npm isn't installing it before running the prepublish action. I have to run npm install separately first, which seems wrong. The same issue exists if I try to npm install the source folder into a different project.
I suspect that I'm "doing it wrong," but the only other guidence I've seen is to compile on install rather than publish. I'd rather not do that, so I'm hoping there are examples of prepublish compilation that I can crib from.