Is it okay to use NPM packages along Composer in Laravel PHP project - npm

Is it okay to install and use NPM for JS libraries along composer in laravel because laravel dependency already includes composer. Thanks.

Yes. This is standard Laravel functionality.
NPM regulates the JS packages in the node_modules folder.
Both NPM and NODE.js need to be installed on your machine: https://blog.teamtreehouse.com/install-node-js-npm-windows
Composer regulates the PHP packages in the vendor folder.
This also needs to be installed separately on your machine: https://laravel.com/docs/4.2
Not sure what you mean by:
... because laravel dependency already includes composer.
Composer is needed anyway, no need to see it as a complication.

Related

NPM dependency from Gitlab directly

I have a situation where there was an update in one of npm packages I use in my project, but author didn't publish it on npmjs registry, so up to date code sits in gitlab only.
What would be the best solution to get updated version of code? I believe there is a way to add dependency to project which will be downloaded from gitlab or github public repository directly? Is it possible to compile it like in npmjs as well?
Yes, you could install a dependency from a git repository directly. As can be seen in the npm docs. You can straight install a Git Remote repository like this:
npm install <git remote url>
e.g.
npm install git://github.com/npm/cli.git
But beware that installing directly from the source git might have unintended side effects (missing build files, additional documentation files in general changes to the npmjs Version).
Also installing from the repository I would recommend you install from a specific commit/Tag.

Install React-Admin package from specific branch or with open pull request

I am having difficulties trying to install a development branch of React-Admin packages with NPM in an active project, specifically:
ra-tree-ui-materialui
ra-tree-core
To have the changes made in this PR https://github.com/marmelab/react-admin/pull/3379
Is there any way of doing this in a similar way to how you normally would put this in package.json ("username/repo#branch")
It is difficult to install a local version of one of React Admin's package, because we use a mono-repository that contains all the packages.
I see two solutions to your needs.
Install the alpha builds
The core team had just published an alpha for the next version of React Admin. It's not stable yet, but you can try it by running :
npm install --save ra-tree-core#next
npm install --save ra-tree-ui-materialui#next
Install a local version for development
If you want to tweak the React Admin packages while you are using them, you can fork the whole repo and use symbolic links.
# On a separate folder
git clone git#github.com:marmelab/react-admin.git
cd react-admin
make install
make build
cd packages/ra-tree-core
npm link # This will make this package available for linking
And on your project, then run:
npm link ra-tree-core
This will create a symbolic link between your local ra-tree-core and your node_module folder.
I showed these examples with npm, but yarn link works too.

Local versus global packages for Angular development

When developing with Angular, one can
npm install
to install packages locally, or
npm install -g
to install them globally. I am wondering what are the implications of each practice. And what happens if a particular package is installed both ways, perhaps with different versions? Which one will my Angular app use?
From there https://www.quora.com/When-do-I-install-a-package-locally-or-globally-in-NPM
In general, the rule of thumb is:
1. If you’re installing something that you want to use in your program, using
import { 'whatever'}, then install it locally, at the root of your project.
2. If you’re installing something that you want to use in your shell, on the command line or something, install it globally, so that its binaries end up in your PATH environment variable.

Why does coffeescript need to be installed globally?

I have a jenkins build that is failing with the following error:
+ npm install
npm WARN prefer global coffee-script#1.12.4 should be installed with -g
Curious as to why coffee-script, or any package for that matter, needs to be installed globally?
Because coffeescript is a command line tool which can transpile coffeescript into javascript, or run as as an interactive shell similar to node.
from the NPMJS docs:
There are two ways to install npm packages: locally or globally. You choose which kind of installation to use based on how you want to use the package.
If you want to use it as a command line tool, something like the grunt CLI, then you want to install it globally. On the other hand, if you want to depend on the package from your own module using something like Node's require, then you want to install locally.
It would technically be possible to install these CLI packages locally, but then you would have to run them using a relative path such as(untested):
./node_modules/coffeescript/bin/coffeescript

ember-cli packages installation

Why some npm packages for ember-cli (like ember-cli-simple-auth or ember-cli-simple-auth-token) needs to be installed with the following two statements
npm install --save-dev ember-cli-simple-auth-token
ember generate simple-auth-token
?
I don't actually understand the second one which apparently simply add a bower dependency:
bash
me#imac1 ~/dev/wishhhh/ember $ ember generate simple-auth-token
version: 0.1.2
installing
Installing browser packages via Bower...
cached git://github.com/simplabs/ember-simple-auth-component.git#0.6.7
Installed browser packages via Bower.
Why do I need it?
You are correct in that all it does is install a bower package.
The reason this is requires is it prevents duplicate bower dependencies in your app. Early in addon development, people were installing bower components with an npm postInstall hook. While this worked, it added a lot of extra file size and possible conflicting bower dependencies.
This is the current pattern that addon developers are using to include bower dependencies in your project. This will likely be changed in the future but that is why for now.
(Answered referencing ember-cli 0.1.2)