-
Notifications
You must be signed in to change notification settings - Fork 28
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
ENOENT: no such file or directory, open './package-lock.json' #10
Comments
You should only add If |
IMO In my case, I just wanted to simply create a fresh lockfile and removed the existing one. Than I had to remove preinstall script, run I don't see any downsides on a silent exit |
@janrembold I agree it could show a warning instead of throwing an error if the FYI If you just want to create a fresh lock file, you can run the following commands:
|
@ronaldbarendse Fair point 🤔 Would it be possible to run |
An issue popped up in production today that I had to resolve quickly and had to override a nested package. Ran into a problem using |
@lazar-vuckovic You're having a totally different issue, as this command shouldn't even be executed on a CI build. The |
I'm running in to the same error with our package that uses |
After digging deeper, it looks like I've encountered the same problem @lazar-vuckovic had: I've updated the "scripts": {
"postshrinkwrap": "npx --quiet npm-force-resolutions && npm install --no-package-lock --no-audit --no-fund --no-progress --silent"
} |
I worked around this issue by doing this:
With this matching script: if [ -f package-lock.json ]; then
npx npm-force-resolutions
fi ...but while this solves the immediate problem, it means my project can't be build on Windows, as was previously possible. If you have some objection to what everyone else is suggesting, that |
I'll definitely try this, @nhartner. If this does the trick, it'll be a fantastic work-around. |
Eh, spoke too soon. It worked locally but not once I published it to npmjs. |
@nhartner, your trick did work in my project, but I'm not publishing an npm package, so maybe that has something to do with it. My project is a VSCode extension. I started from a clean slate (throwing away my whole node_modules folder and package-lock.json), did an Update: Works great for me in another project too. It's interesting that I can see the warning |
You could also add |
Not ideal but works :) |
hello there try |
@edgar-arroyo-by I like your solution a lot, especially as this problem even also appears when installing the package you're using this dependency with as a dependency of another project. I've previously built a more complicated solution that would break in other constellations like e.g. PowerShell, but your solution is clean and simple. Awesome ! |
To anyone experiencing this issue, feel free to try: https://www.npmjs.com/package/force-resolutions Just change: "preinstall": "npx npm-force-resolutions" To: "preinstall": "npx force-resolutions" npx force-resolutions does not run when no package-lock.json is detected, and allows the next command inline to be executed as normal. This is useful when installing dependencies for a package that has been already published where package-lock.json is not available. Feedback and PR's are welcome |
If all of the above answers don't work and you still get sh: npm-force-resolutions: command not found try the following: Just change: "preinstall": "npx npm-force-resolutions" To: "preinstall": "npx force-resolutions" npx force-resolutions does not run when no package-lock.json is detected, and allows the next command inline to be executed as normal Credit to: rogeriochaves/npm-force-resolutions#10 (comment)
@edgar-arroyo-by "preinstall": "npm install --package-lock-only --ignore-scripts && npx npm-force-resolutions", scripts |
It worked in my case |
i am using pnpm instead of npm, so i don't have package-lock.json , i have pnpm-lock.yaml, how to solve this error in such situation? |
If I try to force resolutions before package-json is present, I get the error:
ENOENT: no such file or directory, open './package-lock.json'
The only workaround is to delete the preinstall instruction, do npm install, then readd the npm force resolutions and then npm install again, but this workaround isn't ideal for automated build systems. Is there any solution?
The text was updated successfully, but these errors were encountered: