GithubHelp home page GithubHelp logo

kevinsqi / react-calendar-heatmap Goto Github PK

View Code? Open in Web Editor NEW
1.2K 25.0 157.0 3.27 MB

An svg calendar heatmap inspired by github's contribution graph

Home Page: http://www.kevinqi.com/react-calendar-heatmap/

License: MIT License

JavaScript 96.00% CSS 4.00%

react-calendar-heatmap's Introduction

React Calendar Heatmap

A calendar heatmap component built on SVG, inspired by github's commit calendar graph. The component expands to size of container and is super configurable. Try it out on CodeSandbox.

npm version Build Status bundle size

react-calendar-heatmap screenshot

Setup

Install the npm module with yarn or npm:

yarn add react-calendar-heatmap

Usage

Import the component:

import CalendarHeatmap from 'react-calendar-heatmap';

Import styles. You can directly import from the module, which requires a CSS loader:

import 'react-calendar-heatmap/dist/styles.css';

A CSS loader is included by default in create-react-app. If you don't have a CSS loader, you can simply copy the stylesheet into a file in your project and import it instead.

To show a basic heatmap from January 1st to April 1st:

<CalendarHeatmap
  startDate={new Date('2016-01-01')}
  endDate={new Date('2016-04-01')}
  values={[
    { date: '2016-01-01', count: 12 },
    { date: '2016-01-22', count: 122 },
    { date: '2016-01-30', count: 38 },
    // ...and so on
  ]}
/>

Props

Name Type Description
values Required, Array of Object Required array of objects which each have a date property, which can be a Date object, parseable string, or millisecond timestamp. Example: [{ date: '2016-01-01', count: 6 }]
startDate String, Number, or Date Start of date range.
endDate String, Number, or Date End of date range - a Date object, parseable string, or millisecond timestamp.
showMonthLabels Boolean Toggle for removing month labels.
showWeekdayLabels Boolean Toggle for removing weekday labels.
showOutOfRangeDays Boolean Toggle display of extra days in week that are past endDate and before beginning of range.
horizontal Boolean Whether to orient horizontally or vertically. Can be used in combination with numDays/endDate to show just the current month.
gutterSize Number Size of gutters relative to squares.
onClick Function Callback to invoke when a square is clicked, e.g. (value) => alert(value)
onMouseOver Function Callback to invoke when mouse pointer is over a square, e.g. (event, value) => console.log(event, value)
onMouseLeave Function Callback to invoke when mouse pointer leaves a square, e.g. (event, value) => console.log(event, value)
titleForValue Function Function to determine each square's title attribute, for generating 3rd party hover tooltips (may also need to configure tooltipDataAttrs). Example: (value) => Date is ${value.date}`
tooltipDataAttrs Object or Function Set data attributes for all squares, for generating 3rd party hover tooltips. Either an object like { 'data-tooltip': 'tooltip' } or a function like (value) => { return { 'data-tooltip': 'Tooltip: ' + value } }
classForValue Function Callback for determining CSS class to apply to each value, e.g. (value) => (value.count > 0 ? 'blue' : 'white').
monthLabels Array of String An array with 12 strings representing the text from January to December, e.g. ['01', '02', ..., '12']
weekdayLabels Array of String An array with 7 strings representing the text from Sunday to Saturday
transformDayElement Function A function to further transform generated svg element for a single day. Can be used to attach event handlers, add tooltips and more. Example: (element, value, index) => React.cloneElement(element, { title: value.date }).

Configuring colors

To use the color scale shown in the live demo based on the github contribution graph, you can set the classForValue prop, a function that determines which CSS class to apply to each value:

<CalendarHeatmap
  values={[
    { date: '2016-01-01', count: 1 },
    { date: '2016-01-03', count: 4 },
    { date: '2016-01-06', count: 2 },
    // ...and so on
  ]}
  classForValue={(value) => {
    if (!value) {
      return 'color-empty';
    }
    return `color-scale-${value.count}`;
  }}
/>

Then you use CSS to set colors for each class:

.react-calendar-heatmap .color-scale-1 { fill: #d6e685; }
.react-calendar-heatmap .color-scale-2 { fill: #8cc665; }
.react-calendar-heatmap .color-scale-3 { fill: #44a340; }
.react-calendar-heatmap .color-scale-4 { fill: #1e6823; }

Contributing

Take a look at CONTRIBUTING.md to see how to develop on react-calendar-heatmap.

License

react-calendar-heatmap is Copyright ยฉ 2016 PatientsLikeMe, Inc. and is released under an MIT License. See COPYING for details.

react-calendar-heatmap's People

Contributors

anajavi avatar easingthemes avatar evan-007 avatar gitname avatar hmorgancode avatar kaacun avatar kenkoooo avatar kevinsqi avatar mhienle avatar nbudin avatar okize avatar otakustay avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-calendar-heatmap's Issues

in ios , calender-heat-map does not show.

I use this in app made by Next.js.
I can see calender-heat-map in macbook, however, in ios, calender-heat-map does not appear.
This error Problem parsing viewBox="0 0 NaN 120" occurred. Then, svg tag cannot be appeared.
I read this library code and I think getViewBox() does not work well in ios........

Viewbox Cutting off Months

Love the component! I was wondering if you could expose the getViewBox() method. with 0 0 x y, the top of my months are getting cut off. Make the view box 0 -1 x y does the trick but I can't find a way to do that programmatically.

screen shot 2018-03-28 at 12 36 17 pm

Handle CSS better

Import CSS directly into module IF it allows style overriding.

Else - move css file out of /demo (need to build with webpack?). Into /src or /dist?

Heatmap is microscopic

`
<CalendarHeatmap
startDate={new Date("2018-07-01")}
endDate={new Date("2018-09-10")}
numDays="70"
showMonthLabels="false"

                          values={[
                            { date: "2018-07-01", count: 4 },
                            { date: "2018-07-02", count: 4 },
                            { date: "2018-07-03", count: 4 },
                            { date: "2018-07-04", count: 4 },
                            { date: "2018-07-05", count: 4 },
                            { date: "2018-07-06", count: 4 },
                            { date: "2018-07-07", count: 4 },
                            { date: "2018-07-08", count: 4 },
                            { date: "2018-07-09", count: 4 },
                            { date: "2018-07-10", count: 4 },
                            { date: "2018-07-11", count: 4 },
                            { date: "2018-07-12", count: 4 },
                            { date: "2018-07-13", count: 4 },
                            { date: "2018-07-14", count: 4 },
                            { date: "2018-07-15", count: 4 },
                            { date: "2018-07-16", count: 4 },
                            { date: "2018-07-17", count: 4 },
                            { date: "2018-07-18", count: 4 },
                            { date: "2018-07-19", count: 4 },
                            { date: "2018-07-20", count: 4 },
                            { date: "2018-07-21", count: 4 },
                            { date: "2018-07-22", count: 4 },
                            { date: "2018-07-23", count: 4 },
                            { date: "2018-07-24", count: 4 },
                            { date: "2018-07-25", count: 4 },
                            { date: "2018-07-26", count: 4 },
                            { date: "2018-07-27", count: 4 },
                            { date: "2018-07-28", count: 4 },
                            { date: "2018-07-29", count: 4 },
                            { date: "2018-07-30", count: 4 },
                            { date: "2018-08-01", count: 4 },
                            { date: "2018-08-02", count: 4 },
                            { date: "2018-08-03", count: 4 },
                            { date: "2018-08-04", count: 4 },
                            { date: "2018-08-05", count: 4 },
                            { date: "2018-08-06", count: 1 },
                            { date: "2018-08-07", count: 1 },
                            { date: "2018-08-08", count: 1 },
                            { date: "2018-08-09", count: 1 },
                            { date: "2018-08-10", count: 1 },
                            { date: "2018-08-11", count: 1 },
                            { date: "2018-08-12", count: 1 },
                            { date: "2018-08-13", count: 1 },
                            { date: "2018-08-14", count: 1 },
                            { date: "2018-08-15", count: 1 },
                            { date: "2018-08-16", count: 1 },
                            { date: "2018-08-17", count: 1 },
                            { date: "2018-08-18", count: 1 },
                            { date: "2018-08-19", count: 1 },
                            { date: "2018-08-20", count: 1 },
                            { date: "2018-08-21", count: 1 },
                            { date: "2018-08-22", count: 1 },
                            { date: "2018-08-23", count: 2 },
                            { date: "2018-08-24", count: 2 },
                            { date: "2018-08-25", count: 2 },
                            { date: "2018-08-26", count: 2 },
                            { date: "2018-08-27", count: 2 },
                            { date: "2018-08-28", count: 2 },
                            { date: "2018-08-29", count: 2 },
                            { date: "2018-08-30", count: 2 },
                            { date: "2018-09-01", count: 2 },
                            { date: "2018-09-02", count: 2 },
                            { date: "2018-09-03", count: 2 },
                            { date: "2018-09-04", count: 2 },
                            { date: "2018-09-05", count: 2 },
                            { date: "2018-09-06", count: 2 },
                            { date: "2018-09-07", count: 2 },
                            { date: "2018-09-08", count: 2 },
                            { date: "2018-09-09", count: 2 },
                            { date: "2018-09-10", count: 2 }
                          ]}
                        />

`
https://i.imgur.com/FlWBZ7z.png

I'm assuming I did something wrong, but I don't know where to start looking to fix it.
My heatmap with 70 values is microscopic, the screenshot I post is at 500% on Chrome.
Any help would be greatly appreciated.

Reverse Order

It would be nice to be able to reverse the order of the calendar, so that the most recent dates are displayed highest.

My use case for this is on mobile phones (where I'm setting the prop horizonal to false), in situations where the user cares most about their recent data.

Months language

Currently, ['Jan', 'Feb', ..., 'Dec'] is hardcoded. It would be nice to allow months' names in other languages or allowing users to set months' names.

Generating wrong Heat map

I created the CalendarHeatmap with startDate={new Date('2018-06-01')} and endDate={new Date('2018-06-30')} . It is not generating heatmap properly. As you can see in the screenshot below the colored box is 01-06-2018 and i am seeing other blocks too before it.

Also the heatmap with title H is for startDate={new Date('2018-08-01')} and endDate={new Date('2018-08-30')} , but it too starts with 02-08-2018.

It starts one day after the start date.

screenshot 2018-09-15 at 4 50 58 pm

value always 'null'

<CalendarHeatmap endDate = {new Date(endCalendar)} numDays = {365} values = {schedulesTimes} onClick = {(value) => { alert(value) }} titleForValue = {customTitleForValue} tooltipDataAttrs = {customTooltipDataAttrs} />
image

when i click the block,
it always alert null,
have any idea? ๐Ÿ˜Š

Calendar not accepting weekday labels

Currently, it looks like the calendar is not accepting any new labels? Additionally the css looks off? Overlapping with the heat map itself.

I'm calling it with:

        <CalendarHeatmap
          endDate={new Date()}
          startDate={beginningDate}
          values={data}
          showWeekdayLabels={true}
          weekdayLabels={['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']}
        />

The displayed image looks like:
screen shot 2018-01-29 at 7 52 09 pm

Start week on Monday instead of Sunday

I would like my calendar to start on Mondays instead of Sundays. I've looked through the docs and the source code but I could not find any optional settings for this.

calendar heatmap

And also, changing the weekdayLabels aka filling in the empty spots in the array does not seem to be working as well.

weekdayLabels={['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']}

Is this something that could be done?

Thanks!

Heat map overflows containing div

Hi, thanks for making this component. Great work!

I am limiting the days to 100 days but find that the map is really tall on some screens. If I add a max height to the div containing the react component, the heatmap renders below the div.

Is there a fix for this issue?

Thanks again.

Fix indexing issue with daylight savings time

There's a missing index in getValueCache due to daylight savings time. Not sure if the time is relevant, but I noticed this around 11:30pm PST when the demo site was breaking here with a null value.date, so I added a temporary fix to the demo for now with the real fix to be done with this issue.

This line of code causes a skipped index 196 corresponding to Nov 4th when daylight savings ends:

screen shot 2018-11-07 at 11 51 47 pm

We likely shouldn't be doing millisecond calculations (which is my mistake).

Heatmap ignoring new startDate and endDate values

When I pass new startDate and endDate props to a CalendarHeatmap component, the component does not update to show the data points that fall within the new date range.

I created an interactive online demo in which people can observe this behavior. The demo is at:
https://codesandbox.io/s/32zxwx5ow1

Here's a depiction (created using the above demo) of the behavior:

  1. โœ… This heatmap is configured (via the props first passed to it) to show the entire year of 2017. It, correctly, is showing both "heatmap data" items (since both have a date in 2017).

image

  1. โŒ On the other hand, this heatmap is configured (via new props passed to it) to show the entire year of 2018. However, it continues to show both "heatmap data" items (which both have a date in 2017, not 2018).

image

Pull Request #57 contains a test that causes this behavior to occur.

Fix build error

npm run build

ERROR in ./~/css-loader!./~/style-loader!./~/css-loader!./src/styles.css
Module build failed: CssSyntaxError: /css-loader!/Users/kevinqi/devel/react-calendar-heatmap/node_modules/style-loader/index.js!/Users/kevinqi/devel/react-calendar-heatmap/node_modules/css-loader/index.js!/Users/kevinqi/devel/react-calendar-heatmap/src/styles.css:5:1: Unknown word
    at Input.error (/Users/kevinqi/devel/react-calendar-heatmap/node_modules/css-loader/node_modules/postcss/lib/input.js:61:22)
    at Parser.unknownWord (/Users/kevinqi/devel/react-calendar-heatmap/node_modules/css-loader/node_modules/postcss/lib/parser.js:457:26)
    at Parser.word (/Users/kevinqi/devel/react-calendar-heatmap/node_modules/css-loader/node_modules/postcss/lib/parser.js:174:14)
    at Parser.loop (/Users/kevinqi/devel/react-calendar-heatmap/node_modules/css-loader/node_modules/postcss/lib/parser.js:60:26)
    at parse (/Users/kevinqi/devel/react-calendar-heatmap/node_modules/css-loader/node_modules/postcss/lib/parse.js:26:12)
    at new LazyResult (/Users/kevinqi/devel/react-calendar-heatmap/node_modules/css-loader/node_modules/postcss/lib/lazy-result.js:61:24)
    at Processor.process (/Users/kevinqi/devel/react-calendar-heatmap/node_modules/css-loader/node_modules/postcss/lib/processor.js:34:16)
    at processCss (/Users/kevinqi/devel/react-calendar-heatmap/node_modules/css-loader/lib/processCss.js:188:11)
    at Object.module.exports (/Users/kevinqi/devel/react-calendar-heatmap/node_modules/css-loader/lib/loader.js:24:2)
 @ ./~/style-loader!./~/css-loader!./src/styles.css 4:14-155

Running inside <StrictMode> gives warning about componentWillReceiveProps

I just tested running react-calendar-heatmap inside a strict mode tree (https://reactjs.org/docs/strict-mode.html).
It gives the following warning:

Warning: Unsafe lifecycle methods were found within a strict-mode tree:
    in StrictMode (at app.js:59)
    in App
    in AppContainer (at main.js:17)

componentWillReceiveProps: Please update the following components to use static getDerivedStateFromProps instead: CalendarHeatmap

Learn more about this warning here:
https://fb.me/react-strict-mode-warnings

getDerivedStateFromProps cannot be used in React 16.3, so this can be resolved with:

  1. raising the peerDependency version of React
  2. or using componentDidMount and componentDidUpdate to do the same thing

Which one is preferred solution?

CSS Loader issue

Hi there,
I am using the react-calender-heatmap in my react js project, the CSS loader has been added to web pack.

I tried to directly import the style sheet from the module but that didn't work.
So I copied the stylesheet from the link and imported it into the project but getting the same css loader issue.

Error:

Error in ./../../../../static/css/react-calender-heatmap/styles.css
Module build failed: Syntax Error 

(5:1) Unknown word

  3 | // load the styles
  4 | var content = require("!!../../../node_modules/css-loader/index.js!./styles.css");
> 5 | if(typeof content === 'string') content = [[module.id, content, '']];
    | ^
  6 | // Prepare cssTransformation
  7 | var transform;

Not able to style the component kindly help.

Feature Show Days

It would be nice if one could additionally display the days on the left side. Like on github.

like Mon, Wed and Fri or so.

tooltip issue

I am trying to get the tooltip to work but nothing is showing up.

I used the code you have in the demo with the following scripts

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
  <script src="//cdnjs.cloudflare.com/ajax/libs/tether/1.3.2/js/tether.min.js"></script>
    <script src="https://cdn.rawgit.com/twbs/bootstrap/v4-dev/dist/js/bootstrap.js"></script>
    <script>
      $(document).ready(function() {
        $('[data-toggle="tooltip"]').tooltip();
      });
    </script>

Inside the CalendarHeatmap component, I added these props

          titleForValue={customTitleForValue}
          tooltipDataAttrs={customTooltipDataAttrs}

with the functions from your demo

const customTooltipDataAttrs = { 'data-toggle': 'tooltip' };
function customTitleForValue(value) {
  return value ? `You're hovering over ${value.date} with value ${value.count}` : null;
}

I do not see any error too, so I am not sure what the problem is...
The calendar is working itself showing the colored squares and when I click on it, it shows the count so that is fine.

Group by month

Hello, It could be awesome to group heatmap by month to get something like:

Screenshot 2019-03-18 at 13 52 16

Blocks to represent weeks not days

Hi,

Is there a possibility for the blocks to represent weeks and not days? I'm looking to build out a vertical calendar heat map displaying a year at a time. So in order to save screen space, I would like each block to represent a week (ie: each row of blocks would be a month).
Eg:
[][][][][] August
[][][][][] July
[][][][][] June
etc...

It would be wonderful if this was possible as I need to multi-select blocks representing weeks/months in order to select a date-range for a chart.

Is this possible with the current rect-calendar-heatmap control?

classForValue not working

I cloned the repo and the color for the heatmap is not wokring as shown in the demo. im getting black instead. (PFA).
repo

can u please tell me what is wrong here.

Calender Heatmap not working

I am using this component to render heatmap, but I am unable to do so. I think the component is not accepting my dataset. I have also tried with fixed dataset.

Here is what my component looks like:

<CalendarHeatmap
                  values={this.createTimelineAnalysisData()}
                  showOutOfRangeDays={false}
/>

This will just render a black heatmap with 6 months, it must be the default I think.

Gradient fill of single day

Hi! Great lib.

I'd like to create some more dynamically colored days but the fill css property is pretty limited. Is there any way I'd be able to define my own xml fills and then point the fill attr to my custom fills?

Thanks

Add mouseOver / mouseLeave props to squares

Request, add mouse events to the squares.
https://github.com/patientslikeme/react-calendar-heatmap/blob/master/src/index.jsx#L196

    return (
      <rect
        key={index}
        width={SQUARE_SIZE}
        height={SQUARE_SIZE}
        x={x}
        y={y}
        title={this.getTitleForIndex(index)}
        className={this.getClassNameForIndex(index)}
        onClick={this.handleClick.bind(this, this.getValueForIndex(index))}
        onMouseOver={(e) => this.props.handleMouseOver ? this.props.handleMouseOver(e, value) : null}
        onMouseLeave={(e) => this.props.handleMouseLeave ? this.props.handleMouseLeave(e, value) : null}
        {...this.getTooltipDataAttrsForIndex(index)}
      />
    );

Pass the value and date of that square and it's pointer event (for x/y coordinates).
This will enable the parent component to get the 'tooltip' event as a prop in a more react way, instead of using a jquery style selector.
If you would prefer not to have ternaries I can change them.

I can send a PR as I have been using my fork for a while.

npm warnings on publish

npm WARN prepublish-on-install As of npm@5, `prepublish` scripts are deprecated.
npm WARN prepublish-on-install Use `prepare` for build steps and `prepublishOnly` for upload-only.
npm WARN prepublish-on-install See the deprecation note in `npm help scripts` for more information.

Calendar not rendered

Hi,

I tried to include this calendar in my app but I get following error:

Warning: React.createElement: type is invalid -- expected a string (for built-in components) 
or a class/function (for composite components) but got: undefined. You likely forgot to export 
your component from the file it's defined in. Check the render method of `StatsCalendar`.
    in StatsCalendar (created by ReactRelayQueryRenderer)
    in div (created by ReactRelayQueryRenderer)
    in ReactRelayQueryRenderer (created by Settings)

My component, mostly done from Readme sample:

import React, { Component } from 'react'
import { Segment } from 'semantic-ui-react'
import { CalendarHeatmap } from 'react-calendar-heatmap'

class StatsCalendar extends Component {
  render () {
    const startDate = new Date('2016-01-01')
    const endDate = new Date('2016-04-01')
    const values = [
      { date: '2016-01-01', count: 1 },
      { date: '2016-01-03', count: 4 },
      { date: '2016-01-06', count: 2 }
    ]

    return (
      <Segment>
        <CalendarHeatmap
          values={values}
          classForValue={gitlabClassForValue}
          titleForValue={customTitleForValue}
          tooltipDataAttrs={customTooltipDataAttrs}
          onClick={customOnClick}
          monthLabels={['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12']}
        />
      </Segment>
    )
  }
}
const customTooltipDataAttrs = { 'data-toggle': 'tooltip' }
function customOnClick (value) {
  if (value) {
    alert(`Clicked on ${value.date.toDateString()} with value ${value.count}`)
  }
}
function customTitleForValue (value) {
  return value ? `You're hovering over ${value.date.toDateString()} with value ${value.count}` : null
}

function gitlabClassForValue (value) {
  if (!value) {
    return 'color-empty'
  }
  return `color-gitlab-${value.count}`
}
export default StatsCalendar

What am I doing wrong?

titleForValue not updating when componentWillReceiveProps

I have a heatmap component and feeding it data from the result of a graphql/apollo query. When refreshing with client cached data (which doesn't call componentDidMount but just componentWillReceiveProps) it does not update the data in the titleForValue

First run (not cached data)

image

Second run (not cached data)

image

Third run (this is cached data, same as first run result set)

image

You can see the colours update properly, but the tooltip stays at what was the last load not from cached data

and I can see in the console that the correct values are being sent in

image

titleForValue is being set as an attribute on <CalendarHeatMap />

titleForValue={v => v ? ${moment(v.date).format('ddd D MMM YYYY')} weight: ${v.count} : ''}

Is there a way to force a refresh of the tooltip data when the component is not doing a full remount

Package installation fails in Windows

Background Info

The package.json file in this package contains the following lines, among others:

  "scripts": {
    "build": "NODE_ENV=production webpack",

My computer is running Windows 7 Professional 64-bit.

The Problem

When I run $ npm install (which runs $ npm build, which maps to the command shown above), the Windows Command Prompt tries to run a command named NODE_ENV. The Windows Command Prompt does not find such a command; so, it shows the following error message:

'NODE_ENV' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `NODE_ENV=production webpack`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\SomeUser\AppData\Roaming\npm-cache\_logs\2017-11-25T07_30_29_787Z-debug.log
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

A Solution... for Windows (at least)

The above error can be avoided by changing the build command to the one shown below, which uses set and &&.

  "scripts": {
    "build": "set NODE_ENV=production && webpack",

With that change in place, I can build the package at the Windows Command Prompt with no errors.

Although that fixes the build process in Windows, it may break it on Mac/Linux (I don't know whether it does or not).

A Possible Solution... for Windows, Mac, and Linux

There is an NPM package called cross-env that I think could be used to solve this problem.

The package's README says:

cross-env makes it so you can have a single command without worrying about setting or using the environment variable properly for the platform. Just set it like you would if it's running on a POSIX system, and cross-env will take care of setting it properly.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.