question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't install sample project

See original GitHub issue

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

% npx --no-install next info
npm ERR! canceled

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/username/.npm/_logs/2022-08-04T11_46_58_425Z-debug-0.log

OS: MacOS Monterey 12.5 npm: 8.15.0 Node.js: 18.7.0

Which example does this report relate to?

blog-starter

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Describe the Bug

Trouble with first install with npx create-next-app --example blog-starter.

Error message is this.

Downloading files for example blog-starter. This might take a moment.

? Could not download "blog-starter" because of a connectivity issue between your machine and GitHub.
✔ Could not download "blog-starter" because of a connectivity issue between your machine and GitHub.
Do you want to use the default template instead? … no

Aborting installation.
Unexpected error. Please report it as a bug:
 DownloadError: Premature close
    at createApp (/Users/username/.npm/_npx/efeac22998af9bf2/node_modules/create-next-app/dist/index.js:317:17028)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async run (/Users/username/.npm/_npx/efeac22998af9bf2/node_modules/create-next-app/dist/index.js:317:23064)

Expected Behavior

It worked fine when the Node version was 16.16.0.

In 18.7.0, I think there is a bug around the sample installation.

To Reproduce

OS: MacOS Monterey 12.5

$ brew install n
$ sudo n latest
// latest version is 18.7.0
$ sudo n use
> 18.7.0
$ npx create-next-app --example blog-starter blog-starter-app

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:6
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

5reactions
titusdmoorecommented, Aug 15, 2022

Any node version < 18 will work. Thanks to @jeferson-sb we know that the issue is in node-tar. He has opened an issue here. The issue is that node-tar extract() emits the close event. Which when in a pipeline causes it to error due to premature close in the newer node versions.

3reactions
balazsorban44commented, Sep 2, 2022

@SukkaW Indeed weird, although this is enough to reproduce the issue:

import { promisify } from "node:util"
import Stream from "node:stream"

import tar from "tar"
import got from "got"

const pipeline = promisify(Stream.pipeline)

pipeline(
  got.stream("https://codeload.github.com/vercel/next.js/tar.gz/canary"),
  tar.extract({ cwd: process.cwd(), strip: 3 }, [
    "next.js-canary/examples/with-mongodb",
  ])
)

To fix this in create-next-app, I’ve tried replacing node-tar with tar-fs, but it has a long-standing PR https://github.com/mafintosh/tar-fs/pull/46 that prevents me from moving the extracted files to the top-level.

A workaround I can see is to catch the ERR_STREAM_PREMATURE_CLOSE error and not throw it in Node 18, as the files actually seems to be extracted correctly.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to Install Setup file of Setup Project
Right-click on your Setup1 project and click View>>Launch Conditions to open following screenshot page, then you can right-click on .NET Framework node to ......
Read more >
Install Project - Microsoft Support
See how to install Project 2013 and 2016 and Project Pro for Office 365.
Read more >
Cannot install UE5 City Sample on external drive "nto enough ...
There's over 1tb of space available on the E drive where I want to install it but it refuses to do it because...
Read more >
Sample Projects Will Not Compile...new installation
I have just installed MPLAB X IDE Beta 4.0 and C18 on Linux (Ubuntu 10.10). None of the Sample Projects will compile. Errors...
Read more >
i started a new project and tried to install Multiplayer Samples ...
i started a new project and tried to install Multiplayer Samples Utilities package but it just gave me a ton of errors.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found