madskristensen / NpmTaskRunner

Visual Studio extension
Other
88 stars 32 forks source link

Custom script fails in task runner context, but succeeds on command line. #24

Closed apawsey closed 8 years ago

apawsey commented 8 years ago

Installed product versions

(folder and project names have been changed to protect the stupid - ie: me in case someone above doesn't like me posting details of this project - I've just started at the company).

I am building a solution with Aurelia and Webpack. First time I've used Webpack so, I fiddled repeatedly running builds via the cmd line, until I could understand everything better, and get everything green. Now everything's fine via the cmd line, but when I now tried to run it through the task explorer, I get a messy error.

So my script is defined in my package.json file as this: "build": "webpack --config webpack.config.js --profile --display-error-details",

(it did include the progress flag, but I removed it after seeing your comment regarding webpack and it not being supported - no change to the issue though).

Running via the cmd line, gives this:

C:\Solution\Something>npm run build

> aurelia-dev-projet@1.0.0-beta.1.1.5 build C:\Solution\Something
> webpack --config webpack.config.js --profile --display-error-details

9454ms build modules
7ms seal
13ms optimize
14ms hashing
27ms create chunk assets
6ms additional chunk assets
2ms optimize chunk assets
2ms optimize assets
95ms emit
Hash: 1f1375d1a8f85ac958ba
Version: webpack 1.12.14
Time: 9631ms
                                 Asset     Size  Chunks             Chunk Names
db812d8a70a4e88e888744c1c9a27e89.woff2  66.6 kB          [emitted]
  f4769f9bdb7466be65088239c12046d1.eot  20.1 kB          [emitted]
 fa2772327f55d8198301fdb8bcfc8158.woff  23.4 kB          [emitted]
  e18bbf611f2a2e43afc071aa2f4e1512.ttf  45.4 kB          [emitted]
  89889688147bd7575d6327160d64e760.svg   109 kB          [emitted]
  32400f4e08932a94d8bfd2422702c446.eot  70.8 kB          [emitted]
448c34a56d699c29117adc64c43affeb.woff2    18 kB          [emitted]
 a35720c2fed2c7f043bc7e4ffb45e073.woff  83.6 kB          [emitted]
  a3de2170e4e9df77161ea5d3f31b2668.ttf   142 kB          [emitted]
  f775f9cca88e21d45bebe185b27c0e5b.svg   366 kB          [emitted]
                             bundle.js   460 kB       0  [emitted]  main
                           1.bundle.js  2.07 MB       1  [emitted]
   [0] multi main 28 bytes {0} [built]
       factory:0ms building:2ms = 2ms
  [15] ./src ^\.\/.*$ 4.55 kB {1} [optional] [built]
       ... -> factory:16ms building:548ms dependencies:82ms
    + 160 hidden modules

However the output from the task runner is like this:

> cmd.exe /c npm run build --color=always -d
npm info it worked if it ends with ok
npm info using npm@1.4.9
> aurelia-dev-project@1.0.0-beta.1.1.5 build C:\Solution\Something
> webpack --config webpack.config.js --profile --display-error-details
npm info using node@v0.10.31
npm info prebuild aurelia-dev-project@1.0.0-beta.1.1.5
npm info build aurelia-dev-project@1.0.0-beta.1.1.5

C:\Solution\Something\node_modules\aurelia-webpack-plugin\index.js:102
          var moduleToIncludeSubModulesFor = subModulesToInclude.find(function
                                                                 ^
TypeError: Object [object Object],[object Object] has no method 'find'
    at C:\Solution\Something\node_modules\aurelia-webpack-plugin\index.js:102:66
    at AureliaWebpackPlugin.<anonymous> (C:\Solution\Something\node_modules\aurelia-webpack-plugin\index.js:57:5)
    at C:\Solution\Something\node_modules\aurelia-webpack-plugin\index.js:90:7
    at C:\Solution\Something\node_modules\webpack\lib\ContextModuleFactory.js:124:5
    at C:\Solution\Something\node_modules\async\lib\async.js:52:16
    at C:\Solution\Something\node_modules\async\lib\async.js:361:13
    at C:\Solution\Something\node_modules\async\lib\async.js:52:16
    at done (C:\Solution\Something\node_modules\async\lib\async.js:246:17)
    at C:\Solution\Something\node_modules\async\lib\async.js:44:16
    at C:\Solution\Something\node_modules\async\lib\async.js:358:17
    at C:\Solution\Something\node_modules\webpack\lib\ContextModuleFactory.js:124:5
    at C:\Solution\Something\node_modules\async\lib\async.js:52:16
    at C:\Solution\Something\node_modules\async\lib\async.js:361:13
    at C:\Solution\Something\node_modules\async\lib\async.js:52:16
    at done (C:\Solution\Something\node_modules\async\lib\async.js:246:17)
    at C:\Solution\Something\node_modules\async\lib\async.js:44:16
    at C:\Solution\Something\node_modules\async\lib\async.js:358:17
    at C:\Solution\Something\node_modules\webpack\lib\ContextModuleFactory.js:112:8
    at ContextModuleFactory.<anonymous> (C:\Solution\Something\node_modules\webpack\node_modules\tapable\lib\Tapable.js:82:11)
    at ContextModuleFactory.<anonymous> (C:\Solution\Something\node_modules\webpack\lib\dependencies\RequireContextPlugin.js:50:4)
    at ContextModuleFactory.<anonymous> (C:\Solution\Something\node_modules\webpack\node_modules\tapable\lib\Tapable.js:84:14)
    at ContextModuleFactory.<anonymous> (C:\Solution\Something\node_modules\webpack\lib\dependencies\RequireContextPlugin.js:32:4)
    at ContextModuleFactory.applyPluginsAsyncWaterfall (C:\Solution\Something\node_modules\webpack\node_modules\tapable\lib\Tapable.js:86:13)
    at ContextModuleFactory.<anonymous> (C:\Solution\Something\node_modules\webpack\lib\ContextModuleFactory.js:103:12)
    at Storage.finished (C:\Solution\Something\node_modules\webpack\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:38:16)
    at Object.oncomplete (fs.js:107:15)
npm info aurelia-dev-project@1.0.0-beta.1.1.5 Failed to exec build script
npm ERR! aurelia-dev-project@1.0.0-beta.1.1.5 build: `webpack --config webpack.config.js --profile --display-error-details`
npm ERR! Exit status 8
npm ERR! 
npm ERR! Failed at the aurelia-dev-project@1.0.0-beta.1.1.5 build script.
npm ERR! This is most likely a problem with the aurelia-dev-project package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     webpack --config webpack.config.js --profile --display-error-details
npm ERR! You can get their info via:
npm ERR!     npm owner ls aurelia-dev-project
npm ERR! There is likely additional logging output above.
npm ERR! System Windows_NT 6.2.9200
npm ERR! command "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\Extensions\\Microsoft\\Web Tools\\External\\\\node\\node" "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\Extensions\\Microsoft\\Web Tools\\External\\npm\\node_modules\\npm\\bin\\npm-cli.js" "run" "build" "--color=always" "-d"
npm ERR! cwd C:\Solution\Something
npm ERR! node -v v0.10.31
npm ERR! npm -v 1.4.9
npm ERR! code ELIFECYCLE
Process terminated with code 1.

Steps to recreate

I haven't been able to recreate another test project at the moment. I would be happy to attempt to debug this, although to be honest, I have no idea how you can debug a task runner extension. I will try and research that so I can step through things in a little more detail.

Current behavior

Build fails in context of task runner, when it succeeds outside of Visual Studio environment.

Expected behavior

Build should succeed in task runner.

scottaddie commented 8 years ago

Out of curiosity, have you already made the VS 2015 External Web Tools change noted here?

apawsey commented 8 years ago

No I hadn't seen that :( I have now, and yep, it fixed it! Thank for the enormously quick resolution. On the plus side, I've now got started with learning how to debug node.js packages :)

madskristensen commented 8 years ago

NodeJS has been updated to the latest and greatest for the ASP.NET Web Tooling RC2 update. When that's available for download you don't have to do this External Web Tools trick again

apawsey commented 8 years ago

Shouldn't the external tools just default to finding the globally installed versions, rather than including a specific version themselves? Enabling and disabling the functionality based on the the availability of the tools? At least then the behaviour would never differ inside or outside of visual studio.

Obviously you will have already thought of this, in all the excellent work you've already contributed. Just wondered why this wouldn't work?

madskristensen commented 8 years ago

@apawsey We're debating it. The problem is that this could break the functionality if people have an old version of node.js or npm installed