After starting with a new ionic app, I can see at bower.json that comes with ionic is in devdependencies. Why is it a devdependency and not a normal dependency?
"devDependencies": {
"ionic": "driftyco/ionic-bower#1.0.0-rc.0"
},
Thanks, I feel confused right now
having devDependencies gives you the opportunity to simplify the steps that drive you from the source files (a git clone of the project) to the production ready app
when you don't need to make changes and (develop) the application, you could just run
bower install --production
or
npm install --production
they work the same
bower install options
-F, --force-latest: Force latest version on conflict
-p, --production: Do not install project devDependencies
-S, --save: Save installed packages into the project’s bower.json dependencies
-D, --save-dev: Save installed packages into the project’s bower.json devDependencies
-E, --save-exact: Configure installed packages with an exact version rather than semver
bower documentation
npm install options
By default, npm install will install all modules listed as
dependencies. With the --production flag (or when the NODE_ENV
environment variable is set to production), npm will not install
modules listed in devDependencies.
npm documentation
This way you take less time to ship the app and don't waste bandwidth downloading stuff you won't need.
Given that, to me, the choice of listing ionic as devDependecy is a poor one: it implies that I could take advantage of this choice to get ready the app for execution this way:
git clone my-project
git cd my-project
npm install --production # ionic not installed here
ionic state restore
ionic build ios
Now, if you ignore the content of /lib folder in your sources, this should not work, and if it works because the ionic-cli does some more checks to save your ass, I think this is unclear.
From what I understand, dependencies are required to run, and devDependencies are only for development, like minification, unit tests, etc.
Both will install when you do npm install but only dependencies will install when you do npm install $package, unless you add the --dev option
Related
when I try to run mediapipe iOS demo by yarn, but I only get a "yarn_install failed: yarn install v1.22.11" response,Oddly enough, my Mac has yarn version 1.22.19, Have you ever been in a situation like this?
change the version config or I can user yarn v1.22.19 to make a successful.
The solution was to replace the yarn with the required version 1.22.11. The source could be downloaded from here
More about the yarn version control here
to do a yarn immutable install for all packages it yarn 2 recommends yarn workspaces focus --production --all, is there a way to do this for just one workspace? reason being I would like to not have all dependencies for everything installed into docker containers for different applications.
Yes,
yarn workspaces focus --production (without --all flag)
installs production dependencies just for the workspace in current working directory. You can also specify the name of the workspace as an argument, e.g.:
yarn workspaces focus --production frontend
I'm building an angular2 app, and I've developed a build profile in TFS to auto-build it.
There are four npm commands:
npm install angular-cli -g
npm install
npm run typings (executes typings install)
npm run build (executes ng build)
And then a Copy Publish Artifact step.
However, even when every step passes, it says Finishing Copy and Publish Build Artifacts, the project has been built, and the files have been moved, the actual build never finishes. I've tried breaking those npm commands into a powershell script, having them as NPM commands within TFS, and running them as CMD commands, but the same thing happens every time. Also, if I just remote into the build server and run the commands by hand, it works just fine.
Any ideas?
We've gone through the same headache recently, and I'd strongly suggest you not rely on TFS Build to restore npm packages. Even when you get that right, it takes long and doesn't deploy the node_modules you need to IIS.
Instead, use WebPack to bundle up your node_modules into a bundle.js.
Reference this in your projects/scripts folder and check it into source control.
Remove any npm install steps in your build process (it won't be required anymore since you're referencing the bundle.js now).
This will increase your quality (no future package version surprises), and speed up your deployment (no need to download npm packages on each build anymore).
It's fairly quick to get Webpack installed and you'll save yourself headaches :)
I see from here https://github.com/jquery/jquery-ui that jquery-ui's latest release is 1.11.4. However, when I use "npm install jquery-ui", it's only 1.10.3. I checked this version in node_modules/jquery-ui/jquery-ui.js.
Is there any way for me to install the latest version?
jQuery-ui specifically needs to be build after installation. To avoid this, use npm install jquery-ui-dist
T J gave the right answer, but it is a bit short / too generic.
The GitHub project is at https://github.com/jquery/jquery-ui/
So the real command would be npm install github:jquery/jquery-ui (you can even skip github: as npm defaults to it).
But this would bring you the latest, unstable version (around 1.12 at time of writing), and it didn't even work when I tried.
So it is better to fetch a tagged version:
npm install github:jquery/jquery-ui#1.11.4
Generic note: AFAIK, if the project hasn't a package.json file, this kind of install can still fail.
Here is the current latest version (1.11.4), same package that bower is using, including all themes.
npm install github:components/jqueryui#1.11.4
You can install it like
npm install github:mygithubuser/myproject
as mentioned in the install documentation
I'm using the rc-slider component in my application and had to
add one feature to meet my needs.
I forked the main repository and pushed my changes to this branch.
In the application, I changed the package.json as below and ran the npm install again:
"rc-slider": "Rodrigora/slider#add-label"
Nothing changed. Seems that npm doesn't update the dependencies.
So, I removed the node_modules and rails cache folder and ran the install command again:
rm -rf node_modules/
rake tmp:cache:clear
npm install
Now, I have this error:
events.js:142
throw er; // Unhandled 'error' event
^
Error: Cannot find module 'rc-slider' from '/Users/rodrigora/project/app/assets/javascripts'
NPM can't find the rc-slider when I using the modified branch.
NPM does not update the dependencies only changing the package.json file?
Should I run some build command to install my branch code?
In npm docs:
"dependencies": {
"rc-slider": "git://github.com/Rodrigora/slider.git#add-label"
}
Also you can use
npm install git://github.com/Rodrigora/slider.git#add-label --save
The above command will add that dependency in your package.json.
Edit:
I miss understood your question. I tried the below fix in the repo that you mentioned and it worked. (you should also have the dependency setup like above)
It is a react project. It is compiled and published to NPM.
So, if you want to install it directly from your github fork, you should make some changes to package.json
Before making changes in package.json install rc-tools globaly:
sudo npm install rc-tools -g
Change the files that should be included:
"files": [
"index.js",
"assets",
"src"
]
and add postinstall script in scripts:
"postinstall": "rc-tools run compile"
Then try installing from github after making these changes in that branch.
You can use git repositories as NPM packages:
"rc-slider": "git://github.com/Rodrigora/slider#add-label"