ember-browserify icon indicating copy to clipboard operation
ember-browserify copied to clipboard

Build fails when using ember-cli-ramdisk

Open IanVS opened this issue 10 years ago • 9 comments

I created an issue at ember-cli-ramdisk [https://github.com/ExpressCheckout/ember-cli-ramdisk/issues/8], but thought you might like to know about this as well. When using that addon, I am unable to import modules. For example if I try to import moment from 'npm:moment'; I get the error:

Error: Cannot find module 'moment' from '/mnt/EmberCliRamdisk/borrowers/core_object-input_staging-HpoS1dc8.tmp'
    at /mnt/sdb1/code/websites/borrowers/node_modules/ember-browserify/node_modules/browserify/node_modules/browser-resolve/node_modules/resolve/lib/async.js:50:17
    at process (/mnt/sdb1/code/websites/borrowers/node_modules/ember-browserify/node_modules/browserify/node_modules/browser-resolve/node_modules/resolve/lib/async.js:119:43)
    at /mnt/sdb1/code/websites/borrowers/node_modules/ember-browserify/node_modules/browserify/node_modules/browser-resolve/node_modules/resolve/lib/async.js:128:21
    at load (/mnt/sdb1/code/websites/borrowers/node_modules/ember-browserify/node_modules/browserify/node_modules/browser-resolve/node_modules/resolve/lib/async.js:60:43)
    at /mnt/sdb1/code/websites/borrowers/node_modules/ember-browserify/node_modules/browserify/node_modules/browser-resolve/node_modules/resolve/lib/async.js:66:22
    at /mnt/sdb1/code/websites/borrowers/node_modules/ember-browserify/node_modules/browserify/node_modules/browser-resolve/node_modules/resolve/lib/async.js:21:47
    at Object.oncomplete (fs.js:108:15)

I have no idea what the actual problem is, which is why I brought it up in both repos.

IanVS avatar Jan 26 '15 04:01 IanVS

Browserify is picky about where your tmp folder lives relative to your node_modules folder. If you can mount the actual ramdisk at your-app/tmp instead of just symlinking it, that would probably solve this. Alternatively, you could try symlinking your node_modules folder into the real ramdisk location, so that code being built there can find it via normal node rules.

ef4 avatar Jan 27 '15 04:01 ef4

@ef4, moving node_modules to /mnt/EmberCliRamdisk/<projectName>/node_modules/ and symlinking back to my project folder seems to be working . . . as long as I don't reboot. :-o

I think I'll just move my Ember project folders to my HDD and avoid the hassle. Thanks for explaining the cause.

IanVS avatar Jan 28 '15 03:01 IanVS

@ef4 we have plans to move the tmp folder outside of the project. We will likely need to fixup how ember-browserify works for that. Can we inform browserify of the correct node_modules root/package.json to review?

stefanpenner avatar Feb 01 '15 22:02 stefanpenner

As far as I know it's not easy. browserify is trying hard to maintain normal node semantics. node is really picky about only using the node_modules hierarchy.

So I think the right thing to make sure that the project's node_modules is available within the build tree that gets passed to browserify. A symlink should suffice.

ef4 avatar Feb 01 '15 23:02 ef4

@ef4 if symlink works, then fantastic. But does leave our windows friends in a bad spot.

I wonder if we can bend substacks arm

stefanpenner avatar Feb 01 '15 23:02 stefanpenner

It worked for me with symlinking node_modules. How would this work for multiple projects if tmp and node_modules both live outside the project folder? I like that ember-cli is self contained as it is now.

IanVS avatar Feb 01 '15 23:02 IanVS

node_modules will remain in the project, tmp will not. It is a hazard for editors and other tools watching `tmp/*

stefanpenner avatar Feb 02 '15 00:02 stefanpenner

@ef4 this will also break with broccoli v1, one thing we could do is make a custom browserify-tmp dir in the project root, thoughts?

stefanpenner avatar Apr 27 '16 04:04 stefanpenner

This will actually need to be revisited, when broccoli 1.0 happens and tmp moves to system tmp. The solution is to symlink (and junction for our windows friends) in node_modules to the basedir of browserify.

stefanpenner avatar Sep 13 '16 23:09 stefanpenner