4

So I'm trying to build the javascriptair/site. Inside the package.jsonThere is an npm script that points at a javascript "command" package-scripts. That repository is found https://github.com/kentcdodds/p-s. In Windows it errors out with a JScript error.

Script: C:[path_to_code]\package-scripts.js
Line: 2
Char: 1
Error: Syntax error
Code: 800A03EA
Source: Microsoft JScript compilation error

So in the package.json, what it has is this

"scripts": {
    "start": "package-scripts"
}

If I change the package.json to the following:

"scripts": {
    "start": "package-scripts.cmd"
}

I can get the server to start. So my question is, why is this happening, and how can we change the package.json to make it cross platform with the same command.

kentcdodds
  • 27,113
  • 32
  • 108
  • 187
comfroels
  • 109
  • 1
  • 8
  • `node package-scripts.js` ? Seems like you try to evaluate node script with microsoft js vm. –  May 12 '16 at 16:28
  • Here's a link to the [github issue](https://github.com/javascriptair/site/issues/98) – comfroels May 12 '16 at 16:29
  • Yeah I tried that, it outputs that it is trying to run it, but then just throws me back to the command prompt. Doesn't actually execute anything – comfroels May 12 '16 at 16:29
  • mh, TBH, i don t understand how this package is supposed to work :x `package-scripts.js` is exporting a simple key/value object and does not do anything. –  May 12 '16 at 17:06

3 Answers3

2

The reason and a workaround are pointed here: https://github.com/javascriptair/site/issues/98#issuecomment-404420108

So the problem is there is a js file in the root of repo with the same base name as binary. And npm on windows first tries to run it as binary instead of looking into './node_modules/.bin' So to workaround an issue just remove .JS from PATHEXT environment variable and restart

I've got the same problem: when there is tslint.js file in the root dir of the package and an npm script in package.json just calls tslint, jscript is fired by npm instead of node, resulting in "Microsoft JScript compilation error" popup. Removing .js from PATHEXT helps.

Konstantin Pelepelin
  • 1,303
  • 1
  • 14
  • 29
1

This is a Node.js module that is meant to be required by another script. It is not designed to be executed by Microsoft JScript and if you try running the script file by itself in Node it will not do anything. This is because all of the internal methods of this particular script are supposed to be externally exposed before use.

Upon further examination it seems that the actual file you are probably looking for is in the bin folder. Run that with the node command and see what happens.

Jonathan Gray
  • 2,509
  • 15
  • 20
-1

What worked for me is that I deleted the node_module, package-lock.json and package.json, there after re-install and restart the editor (VS-Code)...

Nimantha
  • 6,405
  • 6
  • 28
  • 69
amiola
  • 1
  • 1