Problem/Motivation

When attempting to run the npm build scripts (npm run dev, npm run prod, etc), the following error is encountered:

$ npm run dev

> dev
> cross-env NODE_ENV=development postcss $npm_package_config_inputFile -o $npm_package_config_outputFile

Input Error: You must pass a valid list of files to parse
npm ERR! code 1
...

I can confirm the following: Node Version is 12.16.1, NPM Version is 7.5.2

Here is a stack overflow post that describes this known cross-environment issue: https://stackoverflow.com/questions/42166632/how-to-use-npm-config-varia...

Steps to reproduce

  1. Clone a copy of the theme repository to a Windows dev environment
  2. Install all dependencies with npm install command
  3. Attempt to run npm run dev
  4. See following error: Input Error: You must pass a valid list of files to parse

Proposed resolution

There are a few solutions that are proposed in the above Stack Overflow post.
I also found the following:

https://www.npmjs.com/package/cross-var
This would appear to be the lowest friction update, as it would simply replace our existing cross-env usage.

https://www.genui.com/resources/env-variables-json
This would require a little more work. While we would be able to stick with the current dependency of cross-env, we would need to add a .env file, and move the variables there instead. The upside to this is that it would separate the concerns and allow more flexibility for multiple environments.

I don't have a strong opinion either way, but I do think it is important to ensure that we have good cross-platform support in order to allow wide adoption of this powerful starter kit.

Comments

lhockley created an issue. See original summary.

lhockley’s picture

After a little testing, I should correct my previous comment with regards to "replacing cross-env", that is still required. A working fix actually chains both cross-var, and cross-env, like so:
"dev": "cross-var cross-env NODE_ENV=development postcss $npm_package_config_inputFile -o $npm_package_config_outputFile",

opdavies’s picture

This is quite interesting. I suppose another option would be to remove the config input variables and move the values into the commands. This would result in some duplication but might be better than adding more dependencies. I work on a Linux machine primarily so anything that would remove Windows edge-cases in the simplest way would be good.

lhockley’s picture

Yeah. I bounce between Linux (Laptop) and Windows (desktop) primarily.

I don't like duplication, but that is certainly a solution with less friction. It also isn't a duplication that ought to grow, since the build scripts for prod/dev should be the only ones that should ever require the input/output values. Any extensions to the build scripts would probably be out of scope of a starter kit anyways, at which point that can be up to the user to determine.

  • opdavies committed 75f53ce on 4.x
    Issue #3197166: Config variables broken in Windows
    
opdavies’s picture

Status: Active » Fixed

This commit removes the configuration variables and moves them back inline within the scripts.

opdavies’s picture

Version: 4.0.0-rc2 » 4.x-dev

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.