Skip to content
This repository has been archived by the owner on Jun 15, 2024. It is now read-only.

package.json file is not actually copied over in WSL2 #164

Closed
ShlomoVinny opened this issue Mar 21, 2024 · 1 comment
Closed

package.json file is not actually copied over in WSL2 #164

ShlomoVinny opened this issue Mar 21, 2024 · 1 comment

Comments

@ShlomoVinny
Copy link

I've been using serverless-layers for a while and recently have a problem deploying or packaging any projects that use this plugin.
I'm using: Ubuntu 22.04.4 LTS in WSL2
I added a couple logs to Dependencies.js for key: "copyProjectFile", to make sure the paths are correct when running.
The paths are correct and I can see that the plugin actually deletes the old folder in the /.serverless/ dir, creates a new /layers/nodejs/ in it instead, but it does not copy over the package.json file from the specified dependenciesPath.
No errors are thrown, I added a log to the callback to make sure it executes.

       var destFile = path.join(_this2.layersPackageDir, fileName || path.basename(filePath));
        console.info("Copying:", filePath, "To:", destFile);
        copyFile(filePath, destFile, function (copyErr) {
          if (copyErr) throw copyErr;
          console.log("Copied!");
          return resolve();
        });

The log says:

Copying: /mnt/d/myPath/layers/package.json To: /mnt/d/myPath/.serverless/layers/nodejs/package.json
Copied!

But I can see no file has actually been copied and the folder stays empty.

Furthermore, since no error is thrown on copying, even though the file was not copied, the script continues running and tries to install dependencies anyway, but since there's no package.json in the cwd specified for the run command, it falls back to the main package.json of the entire project which is incorrect and actually uses pnpm, so it contains "workspace" version names which cause this error, eventually:

Error: Command failed: npm install --production --only=prod
npm WARN config production Use --omit=dev instead.
npm WARN config only Use --omit=dev to omit dev dependencies from the install.
npm ERR! code EUNSUPPORTEDPROTOCOL
npm ERR! Unsupported URL Type "workspace:": workspace:1.0.0

Obviously the package.json I'm trying to install has no "workspace" version names in it.

@ShlomoVinny
Copy link
Author

Actualyl works just fine, it was another issue that was causing this:

#165

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant