[TIMOB-26352] CLI: node_modules in project root should be handled properly
GitHub Issue | n/a |
---|---|
Type | Improvement |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2021-03-01T16:36:37.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 10.0.0 |
Components | CLI, iOS |
Labels | n/a |
Reporter | Hans Knöchel |
Assignee | Christopher Williams |
Created | 2018-09-02T16:58:54.000+0000 |
Updated | 2021-04-13T12:28:12.000+0000 |
Description
I tried using ReduxJS in Titanium, but it fails because we do not look-up node_modules correctly. It is installed to
node_modules/redux/lib/redux.js
, but Titanium does not look there. This seems to be an issue for many many other Node.js modules as well. A workaround is to copy the library to app/lib (Alloy) or Resources (Classic), but that's not how it's handled in modern JS environments, so this should not be the normal workflow.
To reproduce:
1. Create a new Ti app
2. Run npm init
3. Run npm i redux --save
4. Add import { createStore } from 'redux'
to your app.js / index.js (ES6 enabled)
5. Run your app
I've created a PR that allows you to do npm installs in project root directory and it copies all necessary files to the Resources directory so they can be used at runtime. https://github.com/appcelerator/alloy/pull/950
WIP PR: https://github.com/appcelerator/titanium_mobile/pull/11447
Merged to master, manually cherry-picked all commits to 10_0_X branch for 10.0.0 target.