I am developing an Ionic 2 App on my work computer in my office. Sometimes i want to work on it when i’m home. So i created my ionic 2 project in a dropbox folder, that is synced online on every devices. Unfortunately if my home laptop get’s all the current data from the dropbox, i can’t do anything with the ionic install, because every command failes due to the following error:
Error: Cannot find module '../dist/index'
at Function.Module._resolveFilename (module.js:326:15)
at Function.Module._load (module.js:277:25)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/home/chris/Dropbox/Apps/RibalWebentwicklung/node_modules/.bin/ionic-app-scripts:19:3)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Function.Module.runMain (module.js:442:10)
What i have to do then is to completely remove the node_modules folder and reinstall the node modules with
npm install. But when i want to go on working on the app next day on my work computer, i have to do the same there, which breaks the installation on my laptop etc.
How can i work on my app on different computers?
Greetings from germany!
Even if i would share my project with github i would have to clone the project and “fix” the node modules? Ionic and Cordova itself are installed in both machines in the same version.
What about copying the whole project folder onto an usb drive? Would that work? Sorry for the stupid questions.
It is not recommended to copy all files. For example, the node_modules folder is not required to be copied because you can run rpm install.
By using an SCM system like git you can not only share your code, you can also go a step back if you did something wrong.
As a developer, you should learn how to use an SCM. You are lost without it trust me!
And with tools like GitKraken (I recommend this software highly!) you should have any problems with git
This is what company laptops are for. Your question is really one about NodeJS and npm not Ionic. I don’t think there’s a tool to keep your npm libraries synced to the cloud. If someone knows of one, I hope they post. I wouldn’t want to attempt this otherwise – too easy to think your code has a weird bug to find out it’s because of an update issue on one machine but not the other.
I use Dropbox to share code with alpha and beta testers who might add database content but aren’t going to code themselves. The big weakness of Dropbox is lack of version control that a Git-type platform provides. (No “Undo” command so to speak.)
So yeah. I’d suggest you keep it on onne machine, and make regular backups to Dropbox or anywhere else you’d like.
I’d have to agree with not using DropBox and general storage for code sharing. You’ll definitely want to look into source control which, as stated, will give you versioning and rollback management, etc.
GitHub is great for this. I also use BitBucket for personal projects as it allows me to have private repositories for free.
To pile on: Use git, maybe with a free, private repository at Bitbucket. They have SourceTree as a git client, not too bad. You also don’t have to change anything concerning node_modules, it is ignored by default. You just have to
npm install after first checking out the project on your second machine (and remember to do again after adding new dependencies or cordova plugins).