Npm package-lock.json permission denied?

My site name: theoparisdesigns.netlify.com or theoparis.com
github repo: GitHub - theoparis/website-old: creepinson's website
The problem:
So I’ve never had this issue before as netify has built fine yesterday, but when I tried to push some new code it says this in the logs and gives some other errors due to this:

4:31:44 PM: Installing NPM modules using NPM version 6.14.4

4:31:45 PM: npm WARN saveError ENOENT: no such file or directory, open '/package.json'

4:31:45 PM: npm WARN saveError EACCES: permission denied, open '/package-lock.json.3135081923'

4:31:45 PM: npm WARN enoent ENOENT: no such file or directory, open '/package.json'

4:31:45 PM: npm WARN !invalid#2 No description

4:31:45 PM: npm WARN !invalid#2 No repository field.

4:31:45 PM: npm WARN !invalid#2 No README data

4:31:45 PM: npm WARN !invalid#2 No license field.

Not sure what to do as it keeps causing the build to fail due to it not installing node_modules because of these errors. I tried clearing the cache with the retry deploy option.

EDIT: I think I may have found the problem… I was originally using a pnpm monorepo and had set this build prefix setting in netlify.toml from this other post here. After I removed the monorepo it seems like I still had this:
NPM_FLAGS = “–prefix=/”

Hmm, now it seems to be referencing itself:
enoent ENOENT: no such file or directory, access ‘/opt/build/repo/node_modules/client’

The package.json name field is “client”, but why would it be trying to reference itself? It works locally by the way.

Ok, this is weird. There is no “server” folder here anymore, but there was in the past when I was using the monorepo. It keeps thinking theres a monorepo but theres not anymore. I already said I tried clearing netlify’s build cache.

8:27:34 PM: npm WARN checkPermissions Missing write access to /opt/build/repo/node_modules/client
8:27:34 PM: npm WARN checkPermissions Missing write access to /opt/build/repo/node_modules/server

EDIT: So I cleared the build cache like 50 times and now it finally works :man_shrugging:

1 Like