Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

npm Scripts Fail under Windows #12

Closed
TimoStaudinger opened this issue Dec 28, 2018 · 1 comment
Closed

npm Scripts Fail under Windows #12

TimoStaudinger opened this issue Dec 28, 2018 · 1 comment
Labels
has PR already has pull request for it

Comments

@TimoStaudinger
Copy link
Contributor

Running some of the npm scripts, including npm run repl, currently fails in a Windows environment.

This appears to be related to the fact that most Windows command prompts don't deal well with envs set using the FOO=BAR myCommand syntax.

Relevant Logs

Running npm run repl in PowerShell under Windows 10:

PS C:\git\rrweb> npm run repl

> rrweb@0.7.2 repl C:\git\rrweb
> npm run bundle:browser && TS_NODE_CACHE=false TS_NODE_FILES=true ts-node scripts/repl.ts


> rrweb@0.7.2 bundle:browser C:\git\rrweb
> BROWSER_ONLY=true rollup --config

'BROWSER_ONLY' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! rrweb@0.7.2 bundle:browser: `BROWSER_ONLY=true rollup --config`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the rrweb@0.7.2 bundle:browser 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\STA92668\AppData\Roaming\npm-cache\_logs\2018-12-28T19_06_11_024Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! rrweb@0.7.2 repl: `npm run bundle:browser && TS_NODE_CACHE=false TS_NODE_FILES=true ts-node scripts/repl.ts`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the rrweb@0.7.2 repl 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\STA92668\AppData\Roaming\npm-cache\_logs\2018-12-28T19_06_11_099Z-debug.log

Proposed Solution

I suggest introducing the cross-env command line tool, which abstracts away the environment specifics around setting envs.

This should work under any modern environment.

For example:

{
  "scripts": {
    "test": "npm run bundle:browser && cross-env 'TS_NODE_CACHE=false TS_NODE_FILES=true' mocha -r ts-node/register test/**/*.test.ts",
    "repl": "npm run bundle:browser && cross-env 'TS_NODE_CACHE=false TS_NODE_FILES=true' ts-node scripts/repl.ts",
    "bundle:browser": "cross-env BROWSER_ONLY=true rollup --config",
    "bundle": "rollup --config"
  }
}
@TimoStaudinger TimoStaudinger changed the title npm Scripts fail under Windows npm Scripts Fail under Windows Dec 28, 2018
@Yuyz0112
Copy link
Member

Good catch, I use Linux and macOS daily and sorry for this.

I will update both rrweb and its components.

DvdGiessen added a commit to DvdGiessen/rrweb that referenced this issue Dec 29, 2018
@Yuyz0112 Yuyz0112 added the has PR already has pull request for it label Dec 29, 2018
DvdGiessen added a commit to DvdGiessen/rrweb that referenced this issue Dec 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has PR already has pull request for it
Projects
None yet
Development

No branches or pull requests

2 participants