question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

copyFiles causing error: ERROR in unable to locate...

See original GitHub issue

I have been using serverless-bundle for a while now without any issues. Suddenly, when removing my node_modules folder and running npm install, I am now getting an error. Please see my output below when running serverless offline. I get the same error when running serverless deploy.

Serverless: Invoke offline
Serverless: Invoke webpack:validate
Serverless: Using configuration:
{
  "packager": "npm",
  "packagerOptions": {},
  "webpackConfig": "node_modules\\serverless-bundle/src/webpack.config.js",
  "includeModules": {
    "forceExclude": [
      "aws-sdk"
    ],
    "forceInclude": null,
    "packagePath": "package.json"
  },
  "keepOutputDirectory": false
}
Serverless: Removing C:\Users\Stewart\Desktop\Crux Projects Local\Achievement Awards Group\BountiXP Platform\serverless-api\billing\services\billing-address-api\.webpack
Serverless: Bundling with Webpack...
Serverless: Webpack watch invoke: HASH NEW=cf04d716104492eaef2a CUR=null

LOG from copy-webpack-plugin
<e> unable to locate "C:\Users\Stewart\Desktop\Crux Projects Local\Achievement Awards Group\BountiXP Platform\serverless-api\billing\services\billing-address-api\sql\*" at "C:\Users\Stewart\Desktop\Crux Projects Local\Achievement Awards Group\BountiXP Platform\serverless-api\billing\services\billing-address-api\sql\*"
+ 7 hidden lines

ERROR in unable to locate "C:\Users\Stewart\Desktop\Crux Projects Local\Achievement Awards Group\BountiXP Platform\serverless-api\billing\services\billing-address-api\sql\*" at "C:\Users\Stewart\Desktop\Crux Projects Local\Achievement Awards Group\BountiXP Platform\serverless-api\billing\services\billing-address-api\sql\*"

Here is my package.json:

{
  "name": "billing-address-api",
  "version": "0.1.0",
  "description": "bountixp billing-address api",
  "main": "handler.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "bountixp",
  "license": "ISC",
  "devDependencies": {
    "serverless-bundle": "^3.2.1",
    "serverless-offline": "^6.8.0"
  }
}

Here is my serverless.yml:

service: billing-address-api

plugins:
  - serverless-bundle
  - serverless-offline

custom:
  bundle:
    linting: false
    copyFiles:                      # Copy any additional files to the generated package
      - from: 'sql/*'
        to: './'

provider:
  name: aws
  stage: ${opt:stage, 'dev'}
  region: eu-west-1
  runtime: nodejs12.x

functions:
...

I have tried downgrading to v3.0.0. I’ve tried removing my package-lock.json file. No changes have been made to my config since it was previously working, only the npm install, so my thoughts are it must be a dependency package issue of some sort. The issue is only on Windows: Windows 10 Version 1903 (OS Build 18362.1139). Works fine on Ubuntu. Issue can be replicated on my developer’s PC too.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:2
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
stewarthull7commented, Oct 4, 2022

I ran into this issue this morning. Any progress or discoveries about it?

The issue is a posix/win32 path problem.

There is no fix from the author yet, so I’m currently using a self-authored patch with patch-package.

Here is my patch: serverless-bundle+5.5.0.patch

diff --git a/node_modules/serverless-bundle/src/webpack.config.js b/node_modules/serverless-bundle/src/webpack.config.js
index f9b1b76..b74ac1b 100644
--- a/node_modules/serverless-bundle/src/webpack.config.js
+++ b/node_modules/serverless-bundle/src/webpack.config.js
@@ -29,7 +29,7 @@ const defaultConfig = importFresh("./config");
 const isLocal = slsw.lib.webpack.isLocal;
 
 const aliases = config.options.aliases;
-const servicePath = config.servicePath;
+const servicePath = config.servicePath.replace(/\\/g, "/"); // Fix glob issues by converting the path to posix.
 const nodeVersion = config.nodeVersion;
 const externals = config.options.externals;
 const copyFiles = config.options.copyFiles;
@@ -339,7 +339,7 @@ function plugins() {
           return {
             to: data.to,
             context: servicePath,
-            from: path.join(servicePath, data.from),
+            from: path.posix.join(servicePath, data.from), // Fix glob issues by converting the path to posix.
           };
         }),
       })

Note that I’m using version 5.5.0.

0reactions
damien-monnicommented, Oct 4, 2022

I ran into this issue this morning. Any progress or discoveries about it?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error when trying to copy an empty folder with webpack
However this fails when the assets folder is empty: ERROR: unable to locate ... If I add one file to assets folder i...
Read more >
"Cannot find the item" when trying to copy files to thumb drive
Original Title: With some USB thumbdrives & Windows Vista or 7, copying larger files gets a "Cannot find this item" error, telling me...
Read more >
CopyFiles task fails on linux when source tree includes a ...
##[error]Unhandled: Failed find: ENOENT: no such file or ... Dangling symlinks will not cause errors when listing files or checking file ...
Read more >
Fix Unspecified Error When Copying File or Folder ... - EaseUS
Just follow this page and find solutions to fix 'Error Copying ... If you cannot copy files to a destination spot on Windows...
Read more >
cp - Copy files and objects | Cloud Storage - Google Cloud
This causes everything nested under gs://my-bucket/data to be downloaded into dir ... If an error occurs, continue attempting to copy the remaining files....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found