Spine.js and Hem: Getting started - spine.js

I successfully created a Spine app as explained on Spine's Getting started page.
However, Hem doesn't automatically take my changes into account; I have to build manually.
I have the same problem when I follow the contact screencast, but this time Hem does not build at all:
art-mac:spine.contacts art$ hem build
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Cannot find module: spine/lib/tmpl. Have you run `npm install .` ?
I did run 'npm install .'
Surprisingly, when I reinstall spine.contact (in another folder), the contacts I created in the previous contact application appear in the new application...
"Disable cash" in my Chrome development settings in is checked.

I was having the same problem when I first upgraded hem to version 0.1.9. One thing to check for is if there are compiled application.js and application.css files in the public folder of your application. It seems like when these files already exist hem server would serve those files instead of recompiling from the sources. Once those files are removed hem server would then use the source files to dynamically create the application files.
But this behavior did seem a bit different from older versions of hem. I was able to make a couple of changes to the hem server so that it seem to work as before, in that the hem server would always compile from the source files regardless if the application files already existed. I posted the code changes on a similar issue at the hem github repository https://github.com/maccman/hem/issues/46#issuecomment-6550866, but I'm not sure if its a hem issue or if something changed with the strata web server library that hem uses.

The latest Hem in npm (0.2.7) should solve this issue.
The strata server was having issues serving files dynamically if they already existed.

Hem 0.1.9 (the latest version) is not automatically detecting changes to my spine app when running "hem server"(although "hem watch" seems to be working correctly). I was able to get it working by uninstalling 0.1.9 (npm uninstall -g hem) and installing 0.1.8 instead (npm install -g hem#0.1.8).
Regarding your other issue, spine/lib/tmpl is no longer included in the latest version of spine, so if you want to use the screencast you'll need to install whatever version of spine he is using.

Related

Use different versions of the same package in dev or prod?

(not a native speaker, sorry if things don't seems clear)
We are devs for a clients and we work with others devs from another company. The other devs make us a package that we sometimes change this in it, then submit the changes in a pull request.
So we end up having a local version of the package and the official version. And so we want to use the local version in dev (where we might make little changes in the package to match what the client want), and the official in prod (where our changes and other devs changes are merges).
I will show an example that don't work but that can help understand the idea:
[...]
"dependencies"{
[...]
"package":"prod-package"
},
"devDependencies"{
[...]
"package":"local/version/of/package"
},
and so, we should have this:
npm build # use local/version/of/package
npm build --prod # use prod-package
I'm not really good with npm (in fact, beside npm install and npm remove, I basically know nothing), so I might ask something obvious, but I can't find the answer anywere.
Have you tried using npm-link to link to the local version of the package you are consuming? That way, you could still commit your changes to the package back to the vendor.
https://docs.npmjs.com/cli/v8/commands/npm-link
You would essentially run npm link in the checked-out-from-VCS (git?) package folder, then you switch back to your project where you are consuming that package and run npm link {name-of-npm-package}
This would allow you to develop on that version locally, make your changes (and they will show up on VCS for easy pull request management).

Installed package has out-of-date header files

The node-addon-api package is installed and I have been compiling using those header files just fine. But I went to take advantage of a feature and my addon would not compile; the symbol was missing from the headers. After comparing to the header file in their github repository, it was clear that what's installed is not what's current.
The file dates of everything (on a Windows install) is shown as 26-Oct-1985, but I don't know if that's npm just not getting the date right when it writes the file out, or what.
What do I need to do to get the current version in place? npm reports that v.3.0.2 is installed, but even after deleting the directory and letting npm fetch it again, the files are out-of-date.
This was strange; I finally realized that the reason the file kept looking like it was out of date was because the text editor I had it loaded in was not reloading when the file got rewritten by npm -- probably because of the file's datestamp never changing from 26-Oct-85. I discovered this after taking a diff between the installed file and the one in a clone of the package's repo: no difference.

Aurelia au run --watch... not watching

I downloaded an Aurelia project for testing purpose. After restoring the packages (npm install) and running the application (au run --watch). Now I see Start watching... I was curious about doing some changes (for example in contact-list.html) and seeing the website adjusting after pressing F5 (because of watching). It does not work. My changes are not reflecting in the running website. In the shell prompt where it is watching, nothing happened.
You can test by yourself with the project zipped below.
Zip of the Aurelia project
If I create a new Aurelia project from scratch (au new) and following the wizard, the watching works pretty well.
I don't know why it does not work in the project I downloaded (code provided by a Book for learning Aurelia).
What book is this?
Part of the problem is that the version of the CLI you are using is 2 years old. I would recommend getting the latest version of the CLI, creating a new project that uses RequireJS
au new
give new project a name
choose custom (3)
choose RequireJS (2)
choose Babel (1)
choose defaults for the rest
copy the src folder from your zip file over to it the newly created project
You'll need to run npm install bootstrap#3.3.6 --save or yarn add bootstrap#3.3.6 to pull down bootstrap.
Copy the link to bootstrap's css from your zip file's index.html to the new project
Delete the Promise.config line in src/main.js.
Then just run au run (--watch is no longer needed). It should work.

Peer dependency that is also dev dependency of linked npm module is acting as a separate instance

In my app, I have these dependencies:
TypeORM
typeorm-linq-repository AS A LOCAL INSTALL ("typeorm-linq-repository": "file:../../../IRCraziestTaxi/typeorm-linq-repository"), who has a dev dependency AND a peer dependency of TypeORM
The reason I use a "file:" installation of typeorm-linq-repository is that I am the developer and test changes in this app prior to pushing releases to npm.
I was previously using node ~6.10 (npm ~4), so when I used the "file:" installation, it just copied the published files over, which is what I want.
However, after upgrading to node 8.11.3 (npm 5.6.0), it now links the folder rather than copying the published files.
Note, if it matters, that my environment is Windows.
The problem is this: since both my app and the linked typeorm-linq-repository have TypeORM in their own node_modules folders, TypeORM is being treated as a separate "instance" of the module in each app.
Therefore, after creating a connection in the main app, when the code that accesses the connection in typeorm-linq-repository is reached, it throws an error of Connection "default" was not found..
I have searched tirelessly for a solution to this. I have tried --preserve-symlinks, but that does not work.
The only way for me to make this work right now is to manually create the folder in my app's node_modules and copy applicable files over, which is a huge pain.
How can I either tell npm to NOT symlink the "file:" installation or get it to use the same instance of the TypeORM module?
I made it work pretty easily, although I feel like it's kind of a band-aid. I will post the answer here to help anybody else who may be having this issue, but if anybody has a more proper solution, feel free to answer and I will accept.
The trick was to link my app's installation of TypeORM to the TypeORM folder in my other linked dependency's node_modules folder.
...,
"typeorm": "file:../../../IRCraziestTaxi/typeorm-linq-repository/node_modules/typeorm",
"typeorm-linq-repository": "file:../../../IRCraziestTaxi/typeorm-linq-repository",
...

NPM on LEMP cannot find module, wrong path

Total Linux noob here. I am trying to configure a Pleroma development environment on DO droplet. Installed LEMP, installed SSL, installed PostgreSQL, installed Pleroma, so far so good.
Then I installed Node, NPM, cloned Pleroma-FE (apparently it installs in /user/pleroma-fe folder). I am following the very brief build instructions here:
https://git.pleroma.social/pleroma/pleroma-fe
When I get to the command in those build instructions: npm run build
I am getting error: Error: Cannot find module '/user/build/build.js'
It's because actual path to the build file is /user/pleroma-fe/build/build.js
Apologies if this is a duplicate. I see other questions about this.
Fixing npm path in Windows 8 and 10
and the reply seems to set the PATH. This answer might apply to my situation. But my question is: it is clearly already looking in a well defined path (which is different from all the other questions, which don't seem to have well defined path in the error message). But it is the wrong path. How do I make it look in the correct path?
I tried the npm command and specified the complete path, and every variation. and none worked. So it seems fixing the path won't fix this problem.
Sorry I do not currently know enough Linux to be able to fix this. I tried to tag this with Pleroma but I don't have enough reputation to create a new tag. Any help is much appreciated. Thanks in advance.
I continued to work on this with some help of a Linux admin on Fiverr and the Pleroma developers chat with success, thanks to all.
The solution did not involve changing the path. There were several different things going on. First, I needed to change directory into the development project source folder:
cd pleroma-fe
Once I did that, npm found the build module. Next issue was Node was very old and I needed to get the latest version. I used the instruction here for NodeJS (10):
https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions
Next issue was npm was missing some modules. This was fixed with:
npm install
After that the build completed with no errors.
npm run build
After a successful build, you will see a list of files that have changed as a result of the build.
Next issue is that simple changes in HTML text were not live, ie. not reflected in the refreshed web page. This is fixed by copying all the resulting build files to the production folder using rsync. In my case the command was:
rsync -av /user/pleroma-fe/dist/ /home/pleroma/pleroma/priv/static/
Pleroma is a neat Twitter-like user interface to ActivityPub fediverse, it includes a Mastodon UI as well, and thanks to the developers for making it free and open source.