npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

create-repro-ts-node-issue

v0.4.0

Published

![npm version](https://img.shields.io/npm/v/create-repro-ts-node-issue.svg?style=flat-square)

Downloads

18

Readme

npm version

create-repro-ts-node-issue

The entry point of this repository is at ./index.js. It then load a .ts file in ./src to illustrate what happens when registering TS files that import other modules.

Problem description

Running directly: 🌸

It runs fine when called directly with ./index from the command line:

$ ./index
? Who is your favorite Teletubby? (Use arrow keys)
...

Using yarn link: 🌼

It also runs fine when globally linked and run using the bin entry point:

$ yarn link
yarn link v1.7.0
success Registered "create-repro-ts-node-issue".
info You can now run `yarn link "create-repro-ts-node-issue"` in the projects where you want to use this package and it will be used instead.
✨  Done in 0.10s.

Then run from any directory on the file system:

$ create-repo-ts-node-issue
? Who is your favorite Teletubby? (Use arrow keys)
...

So far, so good.

Using yarn create: 🥀

yarn create is a very handy shortcut to bootstrap projects. When running yarn create thingy, yarn will globally install a package called create-thingy then run its executable located in bin, so in theory, it should be very similar to run the yarn linked version.

To achieve this, I had to publish this repo into the create-repro-ts-node-issue npm package.

Then when running the yarn create command, we get:

$ yarn create repro-ts-node-issue
yarn create v1.7.0
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 📃  Building fresh packages...
success Installed "[email protected]" with binaries:
      - create-repro-ts-node-issue
/Users/astorije/.config/yarn/global/node_modules/create-repro-ts-node-issue/src/index.ts:1
(function (exports, require, module, __filename, __dirname) { import inquirer from "inquirer";
                                                              ^^^^^^

SyntaxError: Unexpected token import
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:616:28)
    at Module._extensions..js (module.js:663:10)
    at Object.require.extensions.(anonymous function) [as .ts] (/Users/astorije/.config/yarn/global/node_modules/create-repro-ts-node-issue/node_modules/ts-node/src/index.ts:431:14)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
error Command failed.
Exit code: 1
Command: /usr/local/bin/create-repro-ts-node-issue
Arguments:
Directory: /private/tmp/cht-foo
Output:

Installing globally: 🥀

To reproduce this, we went on using a globally installed version, and got the same result:

$ yarn global add create-repro-ts-node-issue
yarn global v1.7.0
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 📃  Building fresh packages...
success Installed "[email protected]" with binaries:
      - create-repro-ts-node-issue
✨  Done in 6.50s.

$ create-repro-ts-node-issue
/Users/astorije/.config/yarn/global/node_modules/create-repro-ts-node-issue/src/index.ts:1
(function (exports, require, module, __filename, __dirname) { import inquirer from "inquirer";
                                                              ^^^^^^

SyntaxError: Unexpected token import
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:616:28)
    at Module._extensions..js (module.js:663:10)
    at Object.require.extensions.(anonymous function) [as .ts] (/Users/astorije/.config/yarn/global/node_modules/create-repro-ts-node-issue/node_modules/ts-node/src/index.ts:431:14)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)

Versions

$ node --version
v8.11.3

$ yarn --version
1.7.0

$ uname -v
Darwin Kernel Version 17.6.0: Tue May  8 15:22:16 PDT 2018; root:xnu-4570.61.1~1/RELEASE_X86_64