Install npm packages in Titanium - titanium

According to the docs, Titanium now has support to install npm packages: http://docs.appcelerator.com/platform/latest/#!/guide/Node.js_Support
However, upon reading it, I am very confused as to where to actually put my node_modules directory. There is some mention in the docs about a Resources directory, however, for Alloy this is supposed to be left empty, as it is frequently overwritten by the compiler.
So my question is, where do I put my node_modules and how do I reference it.

In Alloy project you are supposed to run npm install inside the app folder. But according to this bug JIRA Ticket modules that use core-modules won't work correctly. So you have to try if you module works.
Another explanation: https://stackoverflow.com/a/45041737/5193915

From experimentation, it seems like you can do npm install in the app/lib/ so your package are in app/lib/node_modules. This does NOT work on the app/ directory.
Note that if you use tishadow, you will also need to install the npm packages there as well in the Resources/ directory (as they still do not use the Alloy framework).

Related

Vue CLI: What exactly happens when I use "npm install"?

I've been using the command line for some time now, but I'm still not sure what exactly happens when I do certain things - and I'm not sure what to google for help.
When I'm working with Anaconda and Python, I found the environments I created in C:\Users\<User>\Anaconda3\envs. And every python package I install in an environment seems to go there. Great!
But how does this work outside of Anaconda/Python? For example, I installed the vue CLI via npm install -g #vue/cli. What exactly happens when I do this; or more precicely, where are files saved?
During the creation of a new vue project, a readme.md is created as well. It states that users should simply npm install to setup the project. It seems that this command installs all packages stated in the package.json. I would like to try out if this command works for new users, but I already (obviously) have everything installed. Can I create some kind of environment (like I do with Anaconda for Python) to accomplish this?
Thanks a lot for your answers!

How does the NPM cache and node_modules folder work hand in hand?

I am trying to demystify this NPM behavior. I have a custom library which I create for an Angular Project. The library is copied directly to the Node modules directory in my Angular Folder to test any new functionalities that I add on whatever project is using it. However, I notice the older version of the library is being used by the project.
I wonder whether this is due to the NPM Cache.
So my question is, how does the NPM cache and Node_Modules folder work hand in hand?
I can't directly answer as to how the cache relates to node_modules, but I can say that your package-lock.json file is likely the culprit behind your outdated packages. Try running npm update. If that doesn't work, try deleting your package-lock.json file and running npm install.
If that also doesn't work, make sure you have the correct version specified for your library in your project's package.json file. latest will grab the latest release available, ^1.0.0 will grab the latest minor and patch releases, ~1.0.0 will grab only the latest patch releases, and 1.0.0 will only grab that exact version.

Install NPM modules on current project while offline

this question might seem stupid but I'm looking for a solution to this scenario:
Let's say I'm starting a new project at an offline environment and I have some npm packages installed globally on my laptop and I'd like to use them for a new project I just created.
For example: I've used npm i -g create-react-app and now I'd like to use create-react-app to make a new react app but I'm currently offline.
I've tried to follow an "offline npm" solution where I basically create an npm server on my computer but I didn't manage to make it work, and am not sure if this will give me the solution I'm looking for.
Sorry if this was answered before, I couldn't find a solution.
Thanks in advance!
You can try run
create-react-app youproject
when you are offline. For me, this sometimes work, sometimes not.
Other solution is install offline all packages, defined in package.json file. You can do this, if you have this packages installed in online mode.
So you can try install this packages, using:
npm link packagename
or
npm i './path_to_package_in_user_directory' // yes, you can also install packages from folder
This solution is also ok, when you try add new packages to existing project. Sometimes this causes error and you need reinstall all packages (that's big pain), but most of all, works good.

How to use ASP.Net Boilerplate Modul Zero Vue.js template?

I downloaded the free template for a single-page application with ASP.Net Core 2.x and EntityFramework Core 2.x. version 3.9.0.
After unpacking the archive, I did not found the project ProjectName.Web.MVC in the solution. If I understand correctly, I need to somehow generate it. But neither on the official documentation site, nor here I found a single word about how to do it. There is a file 3.9.0/aspnet-core/build/build-mvc.ps1 in the archive, maybe I need to use it somehow?
How to compile/generate/create an ProjectName.Web.MVC project for using Vue.js?
I solved this problem as follows.
First, need to understand that when you debug/start a project in VisualStudio, only WebAPI starts. To start vue, you need installed Node.js, Yarn and following npm packages like so:
npm install -g webpack, vue-cli, babel-cli, babel-preset-env
If any packages are redundant, then tell me in comments.
After that, I started the project from VisualStudio and called following NPM commands in the console in vue folder npm install --save-dev. After this dependencies loaded to node_modules folder. At last run npm command npm run serve. Now vue available at URL http://localhost:8080.

install npm package dependency via nexus

So here is the problem
I installed systemjs from the online npm repo to a new empty project which was fine. I then republished this to an internal nexus repository which appeared to work.
However when I tried to install the systemjs repository from our nexus directory, the 'when.js' package was installed within the same node_module level as the systemjs package i.e. myproject->node_modules->when ? Not within myproject->node_modules->systemjs->node_modules->when ?
Can you tell me what I need to do to ensure that the systemjs dependancies are installed within myproject->node_modules->systemjs->node_modules->XXX and NOT myproject->node_modules->XXX ?
Since npm v3 the dependency tree is kept as flat as possible to avoid duplication and overly deep directory structures. That results in placing the dependencies at the same level as the module that required them, unless there already exists another version of the dependency in which case it is installed nested. See the npm documentation for details.
In most cases you shouldn't have to worry about the structure of your node_modules directory. If you absolutely need to have all the dependencies nested, the only way currently seems to be downgrading npm to v2.