Comments (17)
Looks like f4623ba introduced a postinstall
script. That in turn invokes a Babel based build. This change was needed by #52. The problem is that if you rely on history through git, it won't contain a correct build (generated by prepublish
).
I suppose ideally it shouldn't trigger postinstall
if you are treating history as a regular dependency. If it's possible to detect how it was installed (from git or in a normal way), then you can skip Babel build altogether (it will point at lib in this case as it should).
from history.
Are you installing from a git repo, @bryaneaton13?
from history.
@mjackson I'm using npm to install it. npm i history -D
It works when I already have babel installed locally or globally, but on a fresh project install (no babel installed anywhere) with history as a dependency, I get this error.
from history.
@mjackson The problem is that postinstall
, and hence Babel, gets triggered in a regular install as well for some reason. I can see it has a guard in place
node -e \"require('fs').stat('lib', function (e, s) { process.exit(e || !s.isDirectory() ? 1 : 0) })\"
I suppose the question is why that guard might fail in this case. Why else would it try to trigger Babel unless this check fails?
from history.
I get an error on that line also before I get the babel error message.
from history.
@bryaneaton13 Can you provide more info? Which version of Node are you using? Do you get the same error when running the node -e ...
script standalone?
from history.
node -v
v0.10.21
npm -v
1.3.11
If I copy and paste that command without || npm run build
, it completes.
from history.
@bryaneaton13 Are you running on Windows?
from history.
@taion Yep
from history.
I think that's the issue - I believe you can't do cmd1 || cmd2
on Windows.
from history.
I guess that means cmd1 && cmd2
won't work on Windows either, which means our npm test
script is probably broken as well. Nice debugging, @taion.
Now that we know what the problem is, anyone want to make a PR?
from history.
cmd1 && cmd2
actually does work on Windows. It's just the ||
that doesn't work. ¯_(ツ)_/¯
from history.
ok, @bryaneaton13. I think if we use &&
instead of ||
your problem should go away. Can you please try installing from the fix-postinstall-windows
branch?
npm install rackt/history#fix-postinstall-windows
from history.
I think that might break installing when the built files are present, though, since you'd be exiting with a non-zero status code. Per https://docs.npmjs.com/misc/scripts#best-practices:
Don't exit with a non-zero error code unless you really mean it. Except for uninstall scripts, this will cause the npm action to fail, and potentially be rolled back.
from history.
Bah, good point. Any ideas? Last time I wrote code for CMD.exe was at least
a decade ago.
On Thu, Oct 8, 2015 at 5:53 PM Jimmy Jia [email protected] wrote:
I think that might break installing when the built files are present,
though, since you'd be exiting with a non-zero status code. Per
https://docs.npmjs.com/misc/scripts#best-practices:Don't exit with a non-zero error code unless you really mean it. Except
for uninstall scripts, this will cause the npm action to fail, and
potentially be rolled back.—
Reply to this email directly or view it on GitHub
#73 (comment).
from history.
I'm not super familiar with child_process
, because I don't script in Node, but this seems to work:
- "postinstall": "node -e \"require('fs').stat('lib', function (e, s) { process.exit(e || !s.isDirectory() ? 1 : 0) })\" || npm run build"
+ "postinstall": "node -e \"require('fs').stat('lib', function (e, s) { if(e || !s.isDirectory()) require('child_process').spawn('npm', ['run', 'build']) })\""
ETA: I mean it works in Bash, and I think it should work on Windows.
from history.
Ya, I think you're right. Let's try that.
from history.
Related Issues (20)
- Named exports don’t work with Node.js ESM support HOT 1
- Sourcemaps are blank HOT 1
- Use History in redux actions HOT 2
- Location type should have template for unknown for state HOT 3
- doing history.go() does NOT trigger a blocker callback handler HOT 1
- Did TS declaration file disappear for v4? HOT 4
- Wrong action after clicking on Forward button in browser HOT 3
- Need history.BackTo(string)
- Is it possible to access the history bundled into React Router? HOT 1
- globalHistory.pushState function excuted failed in baidu.app
- [v6] Missing hashType={"noslash"} of HashRouter HOT 3
- [react-router-dom v6] HashRouter support HOT 1
- Add index property to BrowserHistory, HashHistory and corresponding Update
- Why `history.length` is gone? HOT 7
- createBrowserHistory() breaks history URL on iOS 11
- history
- is this project abandoned? HOT 2
- Navigate replace without generate new location.key
- hash history url is not parsed correctly with query params
- ReferenceError: document is not defined in Next.JS HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from history.