Hoodie install breaks on my (admittedly unusual) setup
See original GitHub issueI’ve been doing my development on Virtual Machines using Vagrant, and I use a symbolic link on the node_modules directory to prevent it from being synced with my host machine. This causes the hoodie install to fail.
Steps to reproduce:
mkdir proxy
mkdir proxy/node_modules
mkdir app
cd app
ln -nsf ../proxy/node_modules node_modules
npm init -y
npm i -S hoodie
The issue is that setup.js uses path.resolve('..', '..')
to find the App Root, but that leads to the proxy directory and not the app directory where my package.json lives.
I have a workaround, so it’s not a high priority issue for me.
One solution that works for my scenario is to use path.resolve(process.env.PWD, '..', '..')
instead to find the App Root, but I’m not sure if that would break under other setups.
In any case, I think the script should fail gracefully if it can’t find the package.json where it’s expecting. As it is, it’s reverting the entire installation after throwing an exception. It should probably just emit a friendly message: “Hey, couldn’t find your package.json to add the start script.” and exit without reverting the installation.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:6 (3 by maintainers)
Top GitHub Comments
Yeah, my current work-around is to add a symlink in
/proxy
where npm thinks package.json should be and linking it to my actual package.json in/app
. It seems to be working just fine. I just wanted to make sure you were aware of the issue in case it comes up in some other context or so if someone else comes to you with a similar problem you’ll know what’s wrong and be able to help them with it. I agree with the idea of getting rid of the postinstall script in the future.process.cwd()
doesn’t work. It returns the cwd’s “true path”:/proxy/node_modules/hoodie
, whereasprocess.env.PWD
is set by the shell on start-up and returns the path that the shell currently believes is the cwd:/app/node_modules/hoodie
.I’ll try to work on the fail gracefully for now.