Open SkyLeite opened 5 years ago
I had the same issue... turns out after adding a package.json and running npm install
the error is gone
@RodrigoLeiteF @Selion05
I had this same issue, but it seems to be resolved if I place my handlers inside a ./src
folder rather than the root.
Could we consider this issue resolved or do we feel that it needs more attention?
I'm not sure, honestly. I haven't run into this issue after deleting the .build
directory, but something causes it. We can close it if you'd prefer, I wouldn't mind reopening later if needed.
I still get it if i have the node_modules dir in a parent directory (shared with multiple serverless services)
I have my node_modules symlink'd into a service directory and was getting this issue. I symlink'd my package.json and package-lock.json to that same directory and the issue subsided.
buuuut sls deploy does not work. EEXIST: file already exists, symlink '../../node_modules/' -> '.....build/node_modules'
I'm not sure this is a good answer, but here is the change I made locally to get this working:
/**
* Attempt to symlink a given path or directory and copy if it fails with an
* `EPERM` error.
*/
linkOrCopy(srcPath, dstPath, type) {
return __awaiter(this, void 0, void 0, function* () {
return fs.symlink(srcPath, dstPath, type)
.catch(error => {
if (error.code === 'EPERM' && error.errno === -4048) {
return fs.copy(srcPath, dstPath);
}
/* This code returns when the folders/junction already exists */
if (error.code === 'EEXIST' && error.errno === -17) {
return;
}
throw error;
});
});
}
The new code is the second if statement. It seems like everything is working, but I'm not sure this is a complete answer without spending more time with the code.
@kstewart83 it makes sense and should be a PR because the issue stays opened since 2019 and indeed still occurs…
Can confirm that it still exists. In my case I have package.json and my handlers in the same directory.
I am getting also this issue, even when my package.json & project.json are in a parent directory to the handlers (I'm using nx, and the serverless api is in its own nx app folder). I've had to workaround it by manually deleting the .build folder as part of the deploy script.
Im using npm workspaces and this seems to trigger the issue. If move the node_modules folder to the current directory everything works fine, but this isnt how workspaces work
Any update on this?
I get the same issue with workspaces (pnpm)
I removed serverless-plugin-typescript package and did test again. It seems it's worked!
Still exists.
I've solved with this way.
package.json
"scripts": {
...
"prelocal": "rimraf .build",
"local": "serverless invoke local --function function_name --stage local",
...
}
Invoking a function locally with
serverless invoke local -f hello
works the first time, but returns the following error on subsequent runs:Removing the
.build
directory makes it work again.