mizzao / meteor-sharejs

Meteor smart package for transparently adding ShareJS editors to an app
MIT License
225 stars 53 forks source link

500 internal server error for ace.js webclient file #37

Closed swese44 closed 8 years ago

swese44 commented 9 years ago

I upgraded to the latest Meteor version 1.0.2.1 and packages. I upgraded SharJS and added ShareJSAce, everything is running as expected on localhost. But after using demeteorizer to deploy to Modulus Ace never loads. The file "/packages/mizzao_sharejs/.npm/package/node_modules/share/webclient/ace.js" returns a 500 error, here's the server log:

{"line":"457","file":"webapp_server.js","message":"Error serving static file Error: ENOENT, stat '/mnt/data/2/programs/web.browser/packages/mizzao_sharejs/.npm/package/node_modules/share/webclient/ace.js'","time":{"$date":1419661767968},"level":"error"}

You can see the issue here: https://www.seemecode.com/r/h2vaemo

Any ideas why this would be happening? Thanks!

mizzao commented 9 years ago

I'm guessing that running locally uses npm to pull in the ShareJS library, but demeteorizer doesn't do that and hence there is not going to be a .npm folder where the static file is expected to be served from.

https://github.com/onmodulus/demeteorizer says you need to do npm install on the server; did you do this prior to running?

swese44 commented 9 years ago

Yes it gets run by the Modulus CLI command "modulus deploy". I'll open an issue with them and keep this issue updated.

mizzao commented 9 years ago

It doesn't sound exactly like a modulus problem then. Maybe the issue is that all the npm modules go to one place, while, the packages/mizzao_sharejs/.npm path is not rewritten in the code itself.

You may have to do some manual post-processing of the code to make it work. There's probably a better way to do this that does not involve using the funny path, but I haven't figured out a way yet.

brg2 commented 9 years ago

Hello. I'm having a similar issue after deploying to modulus.

{"line":"405","file":"webapp_server.js","message":"Error serving static file Error: ENOENT, stat '/mnt/data/2/programs/web.browser/packages/mizzao_sharejs/.npm/package/node_modules/share/webclient/ace.js'","time":{"$date":1426805272482},"level":"error"}
rubencodes commented 9 years ago

Same exact issue here as above with modulus :(

fiveisprime commented 9 years ago

Demeteorizer relies on the meteor bundle command to generate all of the required assets for the packages included in a project. It looks like bundle is not copying over the .npm directory for some reason. :/

fiveisprime commented 9 years ago

I pushed a possible fix for this to demeteorizer, try running from the include-npm branch of demeteorizer and see if that works.

You can do that by installing from the repository:

$ npm install -g onmodulus/demeteorizer#include-npm

I was able to demeteorize and correctly run the demo included in this repository, but that doesn't guarantee that it will catch all cases. Let me know if anything fails.

For those deploying to Modulus, you'll have to install demeteorizer using the command above then deploy from the .demeteorized directory that is created ($ demeteorizer && cd .demeteorized && modulus deploy)

rubencodes commented 9 years ago

Hmmm...This did something... Led to another issue...Anyone else get this?

rubencodes commented 9 years ago

EDIT: Apologies, the issue I mentioned above turned out to be unrelated. However, I'm still getting the same error after using the new branch of demeteorizer to upload.

{"line":"419","file":"webapp_server.js","message":"Error serving static file Error: ENOENT, stat '/mnt/app/programs/web.browser/packages/mizzao_sharejs/.npm/package/node_modules/share/webclient/ace.js'","time":{"$date":1440042759134},"level":"error"}

fiveisprime commented 9 years ago

@rubencodes what was causing the TypeError: Cannot read property 'done' of null issue that you were seeing? I ran into that while testing some changes.

rubencodes commented 9 years ago

I'm not entirely sure... I just followed the steps a second time and it no longer gave me that error, it just gave me the old error :( So no idea what caused it to begin with... Now it's uploaded, it's started, it just fails with the og error whenever I do anything related to the Ace editor.

Also: Just noticed I'm running an older version of modulus, going to update to 4 and see fi that changes anything.

rubencodes commented 9 years ago

No dice on newest modulus version, same error :/

fiveisprime commented 9 years ago

Try again from that branch, remove and update (I force pushed the changes).

$ npm rm -g demeteorizer && npm install -g onmodulus/demeteorizer#include-npm
rubencodes commented 9 years ago

No dice :( Same issue...When I load the page I get a failed GET request to http://[my domain]/packages/mizzao_sharejs/.npm/package/node_modules/share/webclient/ace.js

fiveisprime commented 9 years ago

This is going to get weird, but bear with me.

Let's take demeteorizer out of the equation by bundling the application using meteor build and seeing if that works. Here are the steps to deploy to Modulus without using demeteorizer (brace yourself!).

Bundle the app (make sure to put your *.onmodulus.net URL here):

$ meteor build --server <your-project-url>.onmodulus.net --directory .modulus-deploy --architecture os.linux.x86_64

Edit package.json to add the correct node version and main file. 🚨 This part is super important to make sure everything runs correctly

$ cd .modulus-deploy/bundle
$ vim programs/server/package.json

With that open add the following lines somewhere within the file (within the main {}).

"engines": { "node": "0.10.36" },
"scripts": { "start": "node ../../main" },

Finally, deploy from the .modulus-deploy/bundle directory and include modules.

$ modulus deploy --include-modules

This method completely avoids any demeteorizer voodoo. My fingers are crossed. :)

mizzao commented 9 years ago

I don't know if that will always work due to the weird binary dependencies in ShareJS, but as long as you build and deploy on the same type of system (i.e. linux x64) that should be fine.

rubencodes commented 9 years ago

Hmm...I added the lines as indicated (triple checked that they were added), but I'm getting the following:

Found package.json: ./programs/server/package.json
WARNING: Main file not specified in package.json.
WARNING: Looking for common main file names: index.js, app.js, server.js, main.js.
ERROR: No main or start script found. There is no application to run.

Should there be a "main" file in the ../../ directory from the package.json? Because all I've got is:

client      packages    server      smart.lock
lib     public      smart.json

at the ../../ directory.

fiveisprime commented 9 years ago

@rubencodes the bundle should look about like this:

.
├── bundle
│   ├── README
│   ├── main.js
│   ├── programs
│   │   ├── server
│   │   │   ├── app
│   │   │   │   └── leaderboard.js
│   │   │   ├── assets
│   │   │   │   └── packages
│   │   │   │       └── boilerplate-generator
│   │   │   │           ├── boilerplate_web.browser.html
│   │   │   │           └── boilerplate_web.cordova.html
│   │   │   ├── boot-utils.js
│   │   │   ├── boot.js
│   │   │   ├── config.json
│   │   │   ├── mini-files.js
│   │   │   ├── npm
│   │   │   ├── npm-shrinkwrap.json
│   │   │   ├── package.json
│   │   │   ├── packages
│   │   │   ├── program.json
│   │   │   └── shell-server.js
│   │   ├── web.browser
│   │   │   ├── 7f34d936fe9105bb301647e4132ec8c80f148a96.js
│   │   │   ├── e60597c923303d5681465135816d98a110781aae.css
│   │   │   ├── head.html
│   │   │   └── program.json
│   │   └── web.cordova
│   │       ├── aadf8805f63511af904f07b3b76b654a6c33aae3.js
│   │       ├── e60597c923303d5681465135816d98a110781aae.css
│   │       ├── head.html
│   │       └── program.json
│   ├── server
│   └── star.json
└── ios
fiveisprime commented 9 years ago

Alright, I got the directions just a little wrong, change the start section to "scripts": { "start": "node ../../main" },

Sorry about that!

rubencodes commented 9 years ago

IT LIVES!!! Thank you! This worked perfectly! So is this just some sort of issue with demeteorizer?

fiveisprime commented 9 years ago

Yeah, demeteorizer uses the old bundle command over build, which seems to have an impact on the structure of the output.

I've started the effort of rewriting demeteorizer to use build, but it will take some time to get there. I suggest using this manual method for now.