Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error message when typescript is missing #977

Closed
steebchen opened this issue Mar 10, 2018 · 4 comments
Closed

Improve error message when typescript is missing #977

steebchen opened this issue Mar 10, 2018 · 4 comments
Labels

Comments

@steebchen
Copy link

When referencing a .ts file and running parcel like this:
parcel index.html
results in this confusing error:

Server running at http://localhost:1234 
🚨  /tmp/parc/index.ts: spawn ENOTDIR
    at _errnoException (util.js:1022:11)
    at ChildProcess.spawn (internal/child_process.js:325:11)
    at Object.exports.spawn (child_process.js:493:9)
    at spawn (/home/luca/.npm-global/lib/node_modules/parcel-bundler/node_modules/cross-spawn/index.js:12:24)
    at Promise (/home/luca/.npm-global/lib/node_modules/parcel-bundler/src/utils/installPackage.js:19:17)
    at Promise (<anonymous>)
    at install (/home/luca/.npm-global/lib/node_modules/parcel-bundler/src/utils/installPackage.js:10:10)
    at **<anonymous>**

It can be solved by simply installing typescript locally:
npm i typescript -D

The error message should be something like "Typescript should be installed l locally" or "Typescript binary is missing".

@davidnagli
Copy link
Contributor

Actually Parcel has a feature that automatically installs dependencies for you. So it actually should install TypeScript for you 100% automatically.

See: #306(merged) and #805(work in progress)

If you look at the error message, notice how at the bottom the error comes from the install() method. Which means that Parcel is actually detecting that you don’t have it installed, and automatically installing if for you, but just it’s failing during that install. The issue is not that parcel is not installing it, it’s that it’s running into some problems while installing typescript.

So looks like this is a problem with error handling in autoinstall.


I tried to reproduce this on my Mac (MacOS High Siera), and I wasn’t able to get the same error. Can you please try to download and run parcel src/index.html on this example I made to see if you get the same error?

Also, can you please fill out the system information table from the issue template.

Here’s my info:

Software Version(s)
Parcel 1.6.2
Node v8.10.0
npm/Yarn yarn:1.3.2 npm:5.6.0
Operating System MacOS High Sierra

@steebchen
Copy link
Author

I see. I cloned the example and it works there, even when I remove typescript in the package.json.
Regardless of what I do, I now can't seem to reproduce this issue either in my first repo... I guess you can close the issue for now until someone experiences this too.
parcel: 1.6.2
node: v8.3.0
yarn: 1.5.1
npm: 5.5.1
os: Linux Mint 18.1 Serena

@DeMoorJasper
Copy link
Member

DeMoorJasper commented Mar 12, 2018

It would be nice to have an obvious error message as the install can still fail.
However this error appears to be a failed spawn for the install script, we could catch those and print a proper error message.

@toby3d
Copy link

toby3d commented Mar 22, 2018

I have this files structure:

/dist/va.js        
/examples/grid.html
/src/va.sass                 

This is a /examples/grid.html:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>Examples Grid</title>
    <script src="../dist/va.js"/>
  </head>
  <body>
    ...
  </body>
</html>

This is a /dist/va.js

require('./../src/va.sass');

module.exports = function () {
  return 2;
};

What I get after run parcel examples/grid.html:

$ parcel examples/grid.html 
Server running at http://localhost:1234 
🚨  /home/toby3d/git/va/src/va.sass:undefined:undefined: spawn ENOTDIR
    at ChildProcess.spawn (internal/child_process.js:330:11)
    at Object.exports.spawn (child_process.js:500:9)
    at spawn (/home/toby3d/.npm-global/lib/node_modules/parcel-bundler/node_modules/cross-spawn/index.js:12:24)
    at Promise (/home/toby3d/.npm-global/lib/node_modules/parcel-bundler/src/utils/installPackage.js:19:17)
    at new Promise (<anonymous>)
    at install (/home/toby3d/.npm-global/lib/node_modules/parcel-bundler/src/utils/installPackage.js:10:10)
    at <anonymous>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants