Skip to content

npm scripts fail with path/command on windows #6

Closed
@Tarabass

Description

@Tarabass

On windows it seems impossible to run the npm scripts. It looks like this has to do with the paths in the scripts in package.json.

Error:

'..' is not recognized as an internal or external command,
operable program or batch file.

npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "run" "build"
npm ERR! node v4.4.7
npm ERR! npm v2.15.8
npm ERR! code ELIFECYCLE
npm ERR! react-app@1.0.0 build: ../../node_modules/.bin/browserify ./src/app.jsx -o ./public/app.js -t babelify
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the react-app@1.0.0 build script '../../node_modules/.bin/browserify ./src/app.jsx -o ./public/app.js -t babelify'.
npm ERR! This is most likely a problem with the react-app package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! ../../node_modules/.bin/browserify ./src/app.jsx -o ./public/app.js -t babelify
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs react-app
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!
npm ERR! npm owner ls react-app
npm ERR! There is likely additional logging output above.

I found a very old issue with the same problem:
npm/npm#2576

The solution, removing the path, is not working of course. This has to do with the folder structure used in this repo.

npm-debug.log

_0 info it worked if it ends with ok
1 verbose cli [ 'C:\Program Files\nodejs\node.exe',
1 verbose cli 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js',
1 verbose cli 'run',
1 verbose cli 'build' ]
2 info using npm@2.15.8
3 info using node@v4.4.7
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info prebuild react-app@1.0.0
6 info build react-app@1.0.0
7 verbose unsafe-perm in lifecycle true
8 info react-app@1.0.0 Failed to exec build script
9 verbose stack Error: react-app@1.0.0 build: browserify ./src/app.jsx -o ./public/app.js -t babelify
9 verbose stack Exit status 1
9 verbose stack at EventEmitter. (C:\Program Files\nodejs\node_modules\npm\lib\utils\lifecycle.js:217:16)
9 verbose stack at emitTwo (events.js:87:13)
9 verbose stack at EventEmitter.emit (events.js:172:7)
9 verbose stack at ChildProcess. (C:\Program Files\nodejs\node_modules\npm\lib\utils\spawn.js:24:14)
9 verbose stack at emitTwo (events.js:87:13)
9 verbose stack at ChildProcess.emit (events.js:172:7)
9 verbose stack at maybeClose (internal/child_process.js:827:16)
9 verbose stack at Process.ChildProcess.handle.onexit (internal/child_process.js:211:5)
10 verbose pkgid react-app@1.0.0
11 verbose cwd D:\Workspaces\Git\react-in-patterns\patterns\composition
12 error Windows_NT 10.0.10586
13 error argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "run" "build"
14 error node v4.4.7
15 error npm v2.15.8
16 error code ELIFECYCLE
17 error react-app@1.0.0 build: browserify ./src/app.jsx -o ./public/app.js -t babelify
17 error Exit status 1
18 error Failed at the react-app@1.0.0 build script 'browserify ./src/app.jsx -o ./public/app.js -t babelify'.
18 error This is most likely a problem with the react-app package,
18 error not with npm itself.
18 error Tell the author that this fails on your system:
18 error browserify ./src/app.jsx -o ./public/app.js -t babelify
18 error You can get information on how to open an issue for this project with:
18 error npm bugs react-app
18 error Or if that isn't available, you can get their info via:
18 error
18 error npm owner ls react-app
18 error There is likely additional logging output above.
19 verbose exit [ 1, true ]

Activity

krasimir

krasimir commented on Jul 26, 2016

@krasimir
Owner

Thanks for reporting. I'll fix that tomorrow morning.

Tarabass

Tarabass commented on Jul 27, 2016

@Tarabass
Author

Unfortunately I did not find any solution. Did you?

krasimir

krasimir commented on Jul 27, 2016

@krasimir
Owner

Nope. I'm rewriting the build steps right now. Should be ready soon.

Best regards

On 27.07.2016 г., at 22:06, Peter Rietveld notifications@github.com wrote:

Unfortunately I did not find any solution. Did you?


You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.

Tarabass

Tarabass commented on Jul 27, 2016

@Tarabass
Author

For what it's worth then, I managed to run the npm scripts by putting "node" before the command:

"build": "../../node_modules/.bin/browserify ./src/app.jsx -o ./public/app.js -t babelify",

But this caused an error with browserify:

basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
          ^^^^^^^

SyntaxError: missing ) after argument list

When this is fixed, maybe it's an idea to put the command in a file 'build.js' and call that from every package.json for reusability?

"build": "node ../../scripts/build.js",

scripts/build.js something like:

var exec = require('child_process').exec;
var cmd = 'node ../../node_modules/.bin/browserify ./src/app.jsx -o ./public/app.js -t babelify';

exec(cmd, function(error, stdout, stderr) {
    console.log('error', error);
    console.log('stdout', stdout);
    console.log('stderr', stderr);
});
krasimir

krasimir commented on Jul 28, 2016

@krasimir
Owner

Yep, I got exactly the same problem. So, we are no longer using relative paths in the package.json scripts. I'm changing the build so we use the main package.json file.

krasimir

krasimir commented on Jul 28, 2016

@krasimir
Owner

@Tarabass the changes are committed now and I tested them under Windows7 by using the default command prompt. No need to go into the patterns directory. Just install the dependencies at the top level npm i and then run npm run build to build the examples or npm run watch if you plan to make changes.

Tarabass

Tarabass commented on Jul 28, 2016

@Tarabass
Author

Using gulp is even better. Thx!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

      Participants

      @Tarabass@krasimir

      Issue actions

        npm scripts fail with path/command on windows · Issue #6 · krasimir/react-in-patterns