-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Scoped packages on forked versions #1414
Comments
@EnoahNetzach Do you have any thoughts on this? |
I don't particularly like to add another cli argument. We could enhance By the way, @danielfigueiredo, is this what you mean? |
I get the error after yarn install: daniel@dan-pc ~/Projects> ./create-react-app/tasks/cra.sh ~/Projects/my-test
+ cd ..
+ root_path=/Users/daniel/Projects/create-react-app
+ /Users/daniel/Projects/create-react-app/node_modules/.bin/lerna bootstrap
Lerna v2.0.0-beta.30
Independent Versioning Mode
Bootstrapping 5 packages
Installing external dependencies
Symlinking packages and binaries
Prepublishing packages
Successfully bootstrapped 5 packages.
+ cd packages/react-scripts
+ cp package.json package.json.orig
+ node /Users/daniel/Projects/create-react-app/tasks/replace-own-deps.js
Replaced local dependencies.
++ npm pack
+ scripts_path=/Users/daniel/Projects/create-react-app/packages/react-scripts/myorg-react-scripts-0.0.5.tgz
+ rm package.json
+ mv package.json.orig package.json
+ yarn cache clean
yarn cache v0.18.1
success Cleared cache.
✨ Done in 4.55s.
+ cd /Users/daniel/Projects/create-react-app
+ node packages/create-react-app/index.js --scripts-version=/Users/daniel/Projects/create-react-app/packages/react-scripts/myorg-react-scripts-0.0.5.tgz /Users/daniel/Projects/my-test
Creating a new React app in /Users/daniel/Projects/my-test.
Installing packages. This might take a couple minutes.
Installing react-scripts...
# ...
# later
# ...
Error: Cannot find module '/Users/daniel/Projects/my-test/node_modules/myorg-react-scripts/package.json'
at Function.Module._resolveFilename (module.js:470:15)
at Function.Module._load (module.js:418:25)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at checkNodeVersion (/Users/daniel/Projects/create-react-app/packages/create-react-app/index.js:229:21) So it can't find the module because the folder structure is:
I'm really sorry if I'm doing something wrong and I'm consuming your time |
I haven't thought about that, it is a good idea. The only problem I see is that if you have a scoped package that is a fork of react-script but doesn't have react-script in the name, like That's why I thought that the |
I think relying on package name could be confusing and unexpected. |
@danielfigueiredo have you checked #1537 out? With this approach any fork must have |
@EnoahNetzach I just rebased from facebook and it works! |
Hello, everyone!
I know we had a PR merged to accept NPM scoped packages in
--scripts-version
, this is another issue. I recently have been maintaining a forked version ofcreate-react-app
where I mostly customized webpack configs to add things like cssnext, stylelint, etc. The problem happened when I updated./packages/react-scripts/package.json
to be a scoped package having thename
to be something like@myOrg/my-package-name
.We all know that scoped packages will create a folder between
node_modules
andreact-scripts
, which is perfectly fine! I had of course to do some tweaks in few relative paths and everything worked.The real problem is not with my published NPM package version, but instead with my local scripts. I'm trying to keep
react-scripts
e2e tests and things working, so that I can automate my fork and make sure the experience with my forked package is always good (things always working).Looking at
./tasks/cra.sh
around line 66 we have something like:So our buddy NPM will look at my scoped package.json:
and will generate a tar file named
danorg-react-scripts-0.0.1.tgz
. Well, things go fine until right after./packages/create-react-app/index.js
performs the install and tries to locate the installedreact-scripts
folder.The
getPackageName
function does:It infers the package name from the tar file, so it thinks the folder is
danorg-react-scripts
but it is actuallydanorg/react-scripts
.I'm having problems trying to figure out the best way to fix this, my thoughts were that
cra.sh
and..../create-react-app/index.js
should be a little bit smarter to figure out the actual package name.A stupid way I found to do it is sending the actual package.json name as an argument to the script.
Let's say that our
cra.sh
as now the following line:But I don't really know if that is the right way to fix this, maybe I shouldn't be using scoped packages.
The text was updated successfully, but these errors were encountered: