madskristensen / NpmTaskRunner

Visual Studio extension
Other
88 stars 32 forks source link

Why package.json private: true causes an issue, (plus 'Defaults' and 'Custom' views) #26

Closed JonPSmith closed 8 years ago

JonPSmith commented 8 years ago

Installed product versions

I have been using your npm task runner successfully for a week or two with a number of custom commands, like webpack build. All has been fine, but I added a new project with a different package.json file and one of the commands won't work. The steps are given below.

Note: The solution will go with a long article I am writing and as such is open-source the actual code can be found at JonPSmith/AspNetReactSamples, ReactTests.

A second minor issue, but one that I would also like to fix if I can, is that the Task Runner Explorer (TRE) window does not look the way you describe it, as it has a Default and Custom section (see point 2 below). It would be create to only have the scripts I have installed, especially for people who want to try it.

Steps to recreate

  1. Add the following code to my package.json file:
  "scripts": {
    "test": "karma start",
    "mytest": "karam start"
  },
  1. Then when I look in the TRE window I see:
    • package.json
    • Defaults
    • install
    • publish
    • restart
    • test
    • Custom
    • mytest
  2. If I run test then it works, with the following log
> cmd.exe /c npm run test --color=always
> reacttests@1.0.0 test C:\Users\Jon\Documents\Visual Studio 2015\Projects\AspNetReactSamples\ReactTests
> karma start
... karma output here....
  1. If I run myTest it fails with the following log
> cmd.exe /c npm run mytest --color=always
> reacttests@1.0.0 mytest C:\Users\Jon\Documents\Visual Studio 2015\Projects\AspNetReactSamples\ReactTests
> karam start
'karam' 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" "mytest" "--color=always"
npm ERR! node v4.4.3
npm ERR! npm  v2.15.1
npm ERR! code ELIFECYCLE
npm ERR! reacttests@1.0.0 mytest: `karam start`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the reacttests@1.0.0 mytest script 'karam start'.
... etc.

Notes

In the solution JonPSmith/AspNetReactSamples the project ReactWebPack.MVC5 works fine, but the project ReactTests does not. I can't see any difference in what I am doing.

Your help would be appreciated.

JonPSmith commented 8 years ago

OK, I found what is different between the two package.json files that fixes this.

If I remove line "private": true from the package.json then my myTest script works!

That's fine and I will continue like that, but for my own education I would like to know why, as I believe the default is for "private": true.

It would also be great to get rid of the Defaults if I can, especially for the article.

madskristensen commented 8 years ago

It has nothing to do with private:true. You made a typo by calling it karam instead of karma

JonPSmith commented 8 years ago

Doh! Really sorry to have wasted your time. I should have seen that!

madskristensen commented 8 years ago

No worries :)