madskristensen / NpmTaskRunner

Visual Studio extension
Other
88 stars 32 forks source link

"Implement me. Unknown stdin file type!" Error when run package.json scripts created by create-react-app. Scripts run from NpmTaskRunner using Yarn. #50

Closed henrydaehnke closed 7 years ago

henrydaehnke commented 7 years ago

Installed product versions

Description

Get "Unknown stdin file type!" when use NpmTaskRunner to run package.json scripts created by create-react-app.

Steps to recreate

  1. Create a blank node.js project in Visual Studio Enterprise 2017.
  2. Create project files using create-react-app in a different directory. In my case, I wanted to use TypeScript so ran following: $ create-react-app my-app --scripts-version=react-scripts-ts
  3. Copied over the files from the create-react-app output to the blank node.js project.
  4. Attempt to run any of the available scripts (e.g. "start", "test", "build") from the Task Runner Explorer window (Note, the project has a yarn.lock file, so yarn is used to run the scripts).

Current behavior

Exception is thrown when attempt to run package.json scripts from NpmTaskRunner using yarn. Here's the error:

C:\project path\project folder> cmd.exe /c yarn run build -d Implement me. Unknown stdin file type! yarn run v0.24.6 $ react-scripts-ts build C:\project path\project folder\node_modules\react-scripts-ts\scripts\build.js:59 ({ stats, previousFileSizes, warnings }) => { ^ SyntaxError: Unexpected token { at exports.runInThisContext (vm.js:53:16) at Module._compile (module.js:373:25) at Object.Module._extensions..js (module.js:404:10) at Module.load (module.js:343:32) at Function.Module._load (module.js:300:12) at Function.Module.runMain (module.js:429:10) at startup (node.js:139:18) at node.js:999:3 error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. Process terminated with code 1.

Expected behavior

Should run without throwing exception. This does work from a command prompt.

scottaddie commented 7 years ago

@henrydaehnke Because this works from the command line, I suggest you make the following change in VS 2017:

  1. Tools > Options > Projects and Solutions > Web Package Management > External Web Tools
  2. Move the $(PATH) entry up to the 2nd item in the list
  3. Click OK
henrydaehnke commented 7 years ago

@scottaddie Nice! That worked. I hadn't thought of fiddling around with the $(PATH) order in Visual Studio. The only slightly odd thing is that the Implement me. Unknown stdin file type! error is still displayed, but everything works. See the error details below when trying to run the start script created by create-react-app.

I am going to close this issue. Thanks again!

Error example (again, still works):

C:\project path\project folder> cmd.exe /c yarn run start Implement me. Unknown stdin file type! yarn run v0.24.6 $ set HTTPS=true&&react-scripts-ts start Starting the development server... Warning: The 'no-use-before-declare' rule requires type checking ts-loader: Using typescript@2.3.3 and C:\project path\project folder\tsconfig.json Compiled successfully! You can now view project-name.web in the browser. https://localhost:3000/ Note that the development build is not optimized. To create a production build, use yarn run build.