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

CRA scripts version as .tgz file bug in Node version 14.x/15.x #10754

Open
jeffrey-vang opened this issue Mar 26, 2021 · 0 comments
Open

CRA scripts version as .tgz file bug in Node version 14.x/15.x #10754

jeffrey-vang opened this issue Mar 26, 2021 · 0 comments

Comments

@jeffrey-vang
Copy link

jeffrey-vang commented Mar 26, 2021

Describe the bug

OS: MacOS 10.15.7 Catalina
Running a command like npx create-react-app . --scripts-version=/some/local/path/to/jv-forked-scripts.tgz --template=cra-template results in an error trying to determine the package name on the scripts package.

My scripts package uses a scoped name like @jv/forked-scripts however the name of the .tgz file that gets created upon npm pack command is jv-forked-scripts.tgz.

Node v12: When using CRA 3.x/4.x in a Node v12 environment, CRA successfully unpacks the .tgz to a temporary location and can correctly infer the package name from the package.json file.

Node v14/v15: When using the same command in a Node v14.x or v15.x environment, I get the following error.

Could not extract the package name from the archive: Cannot find module '/var/folders/10/cdlwly957wzb1mp09v9cppnw0000gp/T/tmp-10364-cuYCB3MNws5F/package.json'

However, when I run a command like ls /var/folders/10/cdlwly957wzb1mp09v9cppnw0000gp/T/tmp-10364-cuYCB3MNws5F/, I can see that my package has been unpacked to this location. I have tried modifying my global cra script to output whether or not the package.json file exists following the unpack command (using fs.existsSync) but it results in a false output. Essentially, CRA is unable to infer the package name and will default to the name of the .tgz file which is not the same as my package name.

This makes is difficult to test local custom scripts and what is ultimately minted does not contain my template.

Did you try recovering your dependencies?

Yes. Always using CRA 4.x

Which terms did you search for in User Guide?

Could not extract the package name from the archive

Environment

OS: MacOS v 10.15.7 Catalina
Node: v14.16 || v15.3
npm: 6.14.11

Steps to reproduce

(Write your steps here:)

  1. npx create-react-app . --scripts-version=/some/local/path/to/jv-forked-scripts.tgz --template=cra-template

Expected behavior

I am expect CRA to begin minting a new project using my packages.
Installing react, react-dom, and @jv/forked-scripts with cra-template

Actual behavior

CRA infers the package name from the filename of the .tgx file.

Could not extract the package name from the archive: Cannot find module '/var/folders/10/cdlwly957wzb1mp09v9cppnw0000gp/T/tmp-10364-cuYCB3MNws5F/package.json'
Require stack:
- /Users/VANGJEF/.nvm/versions/node/v14.16.0/lib/node_modules/create-react-app/createReactApp.js
- /Users/VANGJEF/.nvm/versions/node/v14.16.0/lib/node_modules/create-react-app/index.js
Based on the filename, assuming it is " jv-forked-scripts"
Installing react, react-dom, and jv-forked-scripts with cra-template...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant