-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
[BUG] Unable to resolve reference $react #5730
Comments
That appears to be an invalid |
The $prefix is right from the NPM package documentation: https://docs.npmjs.com/cli/v8/configuring-npm/package-json/ |
I also ran into this issue on the
|
I have this bug too and I can reproduce it quickly with node
And after downgrading to What I noticed is the problem comes when the version is using a tag instead of a version, for example This fails ❌
This works ✅
|
This is still a problem on |
I see the same problem w/ |
Just went into the same bug with The following doesn't work, {
// ...
"dependencies": {
"@babel/core": "^7.20.12"
},
"devDependencies": {
"@trivago/prettier-plugin-sort-imports": "^4.0.0",
},
"overrides": {
"@trivago/prettier-plugin-sort-imports": {
"@babel/core": "$@babel/core",
"@babel/parser": "$@babel/core",
"@babel/traverse": "$@babel/core"
}
}
} But this do work, {
// Same as above
"overrides": {
"@trivago/prettier-plugin-sort-imports": {
"@babel/core": "^7.20.12",
"@babel/parser": "$@babel/core",
"@babel/traverse": "$@babel/core"
}
}
} |
I had the same issue with npm versions e.g. change ...
"overrides": {
"react-native": {
"react": "$react"
},
"craco-less": {
"react": "$react",
"react-dom": "$react",
"@craco/craco": "$@craco/craco"
}
}
... to ...
"overrides": {
"react-native": {
"react": "^17.0.2"
},
"craco-less": {
"react": "^17.0.2",
"react-dom": "$react",
"@craco/craco": "$@craco/craco"
}
}
... re-generate the Hopefully helps someone debug the issue or at least work around it for now |
Also, this seems like a re-occurrence of #4395 which is marked as closed but seems to still be present in npm |
We were running into this weird behaviour with certain
The solution to fixing this was:
If this issue pops up again in a repo, it is probably because someone used |
Just as an additional point of reference, I can reproduce this issue without |
I have an example that fails with npm 9.6.2: {
"name": "override",
"dependencies": {
"ts-jest": "^29.0.5",
"typescript": "^5.0.2"
},
"overrides": {
"typescript": "$typescript"
}
} Without ts-jest it works. Might be related - ts-jest has peerDependency: |
Temporary solution I've found is to delete the override, install, then add back the override, then install again. |
We faced this again with correct using |
When another top level dependency requires the overridden dependency and is resolved before the overridden one, the reference has not been created yet. {
"name": "example",
"dependencies": {
"foo": "^4.2.0",
"bar": "^1.0.0",
},
"overrides": {
"foo": "$foo"
}
} {
"name": "bar",
"dependencies": {
"foo": "^3.2.0",
}
} The order in which the packages are resolved determines whether this works or not. Since |
Ran into the same issue. I deleted package-lock.json and node_modules and reinstalled everything via |
I have had the same problem with $react-native
I just took the suggestion from above and replaced the $react-native variable with the version defined in the devDependencies and it worked fine. |
The variable doesn't seem to work in CI.. npm/cli#5730
The problem of updating dependencies can be solved using |
@Bow2Jesus |
Migrated to eslint 9. Fixed various linting issues found with the new rule set. Also updated to match the latest Vite react-ts template, except for explicitly setting the eslint version override instead of "$eslint", since I'm running into npm/cli#5730.
I'm running into the same issue in https://github.com/joelspadin/xivplan. The Vite react-ts template overrides "eslint" to "$eslint", but if I do the same in my project instead of duplicating the version number between |
Same issue in node: v22.13.1 and npm: 10.9.2 only with devDependencies though. |
Is there an existing issue for this?
This issue exists in the latest npm version
Current Behavior
I am attempting to run npm install to create the node_modules folder with nodes and package-lock.json file from the package.json file. When I run npm install it returns this error message "npm ERR! Unable to resolve reference $react".
Expected Behavior
Since I have react and its version defined in my dependencies, then I expect npm to resolve the reference to react and finish processing my package.json file.
Steps To Reproduce
Environment
; "builtin" config from C:\Program Files\nodejs\node_modules\npm\npmrc
prefix = "C:\Users\i338909\AppData\Roaming\npm"
; "user" config from C:\Users\i338909.npmrc
http_proxy = "http://bcproxy.hcscint.net:8080"
https_proxy = "http://bcproxy.hcscint.net:8080"
proxy = "http://bcproxy.hcscint.net:8080/"
registry = "http://nexus.fyiblue.com/repository/npm-all/"
scripts-prepend-node-path = true
strict-ssl = true
; node bin location = C:\Program Files\nodejs\node.exe
; node version = v16.18.0
; npm local prefix = C:\NMP_TEST\rover-web-app-test
; npm version = 8.19.2
; cwd = C:\NMP_TEST\rover-web-app-test
; HOME = C:\Users\i338909
; Run
npm config ls -l
to show all defaults.The text was updated successfully, but these errors were encountered: