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

Getting cannot find module 'encoding' error #135

Closed
satyarohith opened this issue Jun 30, 2020 · 3 comments
Closed

Getting cannot find module 'encoding' error #135

satyarohith opened this issue Jun 30, 2020 · 3 comments
Assignees
Labels
type: bug code to address defects in shipped code

Comments

@satyarohith
Copy link

Describe the bug

I'm getting 'cannot find module 'encoding' error.

Configuration

netlify.toml

[[plugins]]
   package = "./netlify-plugin-nimbella"

# To install the dependencies of local plugins. 
[[plugins]]
    package = "@netlify/plugin-local-install-core"

[build]
  functions = "functions-build"
  # This will be run the site build
  command =  "npm run build"
  # This is the directory is publishing to netlify's CDN
  publish = "public"
  System:
    OS: macOS 10.15.5
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 1.45 GB / 16.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 14.4.0 - /var/folders/kc/vyh4nng11g16mxpgx5zprjnw0000gn/T/fnm-shell-7324892/bin/node
    Yarn: 1.22.4 - ~/c/github.com/satyarohith/netlify-faunadb-example/node_modules/.bin/yarn
    npm: 6.14.5 - /var/folders/kc/vyh4nng11g16mxpgx5zprjnw0000gn/T/fnm-shell-7324892/bin/npm
  npmPackages:
    netlify-cli: ^2.19.0 => 2.54.0 
  npmGlobalPackages:
    netlify-cli: 2.54.0

Deploy logs

┌────────────────────────────────────────────────────────┐
│ Plugin "@netlify/plugin-functions-core" internal error │
└────────────────────────────────────────────────────────┘

  Error message
  Error: In file "/Users/sr/c/github.com/satyarohith/npn-site/functions-build/todos-list.js": Cannot find module 'encoding'
  Require stack:
  - /Users/sr/.fnm/node-versions/v14.4.0/installation/lib/node_modules/netlify-cli/node_modules/@netlify/zip-it-and-ship-it/src/resolve.js
  - /Users/sr/.fnm/node-versions/v14.4.0/installation/lib/node_modules/netlify-cli/node_modules/@netlify/zip-it-and-ship-it/src/dependencies.js
  - /Users/sr/.fnm/node-versions/v14.4.0/installation/lib/node_modules/netlify-cli/node_modules/@netlify/zip-it-and-ship-it/src/main.js
  - /Users/sr/.fnm/node-versions/v14.4.0/installation/lib/node_modules/netlify-cli/node_modules/@netlify/build/src/plugins_core/functions/plugin.js
  - /Users/sr/.fnm/node-versions/v14.4.0/installation/lib/node_modules/netlify-cli/node_modules/@netlify/build/src/plugins/child/logic.js
  - /Users/sr/.fnm/node-versions/v14.4.0/installation/lib/node_modules/netlify-cli/node_modules/@netlify/build/src/plugins/child/load.js
  - /Users/sr/.fnm/node-versions/v14.4.0/installation/lib/node_modules/netlify-cli/node_modules/@netlify/build/src/plugins/child/main.js

  Plugin details
  Package:        @netlify/plugin-functions-core
  Version:        2.0.23
  Repository:     git+https://github.com/netlify/build.git
  npm link:       https://www.npmjs.com/package/@netlify/build
  Report issues:  https://github.com/netlify/build/issues

  Error location
  In "onPostBuild" event in "@netlify/plugin-functions-core" from core
      at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1029:15)
      at Function.resolve (internal/modules/cjs/helpers.js:79:19)
      at resolvePathFollowSymlinks (/Users/sr/.fnm/node-versions/v14.4.0/installation/lib/node_modules/netlify-cli/node_modules/@netlify/zip-it-and-ship-it/src/resolve.js:62:18)
      at resolvePackageFallback (/Users/sr/.fnm/node-versions/v14.4.0/installation/lib/node_modules/netlify-cli/node_modules/@netlify/zip-it-and-ship-it/src/resolve.js:74:24)
      at resolvePackage (/Users/sr/.fnm/node-versions/v14.4.0/installation/lib/node_modules/netlify-cli/node_modules/@netlify/zip-it-and-ship-it/src/resolve.js:33:27)
      at async getModuleNameDependencies (/Users/sr/.fnm/node-versions/v14.4.0/installation/lib/node_modules/netlify-cli/node_modules/@netlify/zip-it-and-ship-it/src/dependencies.js:138:23)
      at async getModuleDependencies (/Users/sr/.fnm/node-versions/v14.4.0/installation/lib/node_modules/netlify-cli/node_modules/@netlify/zip-it-and-ship-it/src/dependencies.js:116:12)
      at async Promise.all (index 0)
      at async getFileDependencies (/Users/sr/.fnm/node-versions/v14.4.0/installation/lib/node_modules/netlify-cli/node_modules/@netlify/zip-it-and-ship-it/src/dependencies.js:79:21)
      at async getDependencies (/Users/sr/.fnm/node-versions/v14.4.0/installation/lib/node_modules/netlify-cli/node_modules/@netlify/zip-it-and-ship-it/src/dependencies.js:51:12)

  Error properties
  { code: 'MODULE_NOT_FOUND' }

  Resolved config
  build:
    command: npm run build
    environment:
      - NIMBELLA_LOGIN_TOKEN
    functions: /Users/sr/c/github.com/satyarohith/npn-site/functions-build
    publish: /Users/sr/c/github.com/satyarohith/npn-site/public

The error is also getting triggered in the CI.

As far as I could find the encoding module is required in zip-it-and-ship-it:

Feel free to transfer the issue if it belongs there.

Pull requests

Pull requests are welcome! If you would like to help us fix this bug, please check our
contributions guidelines.

@ehmicky ehmicky transferred this issue from netlify/build Jun 30, 2020
@ehmicky ehmicky self-assigned this Jun 30, 2020
@ehmicky ehmicky added the type: bug code to address defects in shipped code label Jun 30, 2020
@ehmicky
Copy link
Contributor

ehmicky commented Jun 30, 2020

Hi @satyarohith,

Thanks for reaching out.

The encoding dependency is not required from the file above. That file is a test fixture that is not published to npm. Most likely, it is required by a deep dependency of one of your Functions.

Is your repository public? If not, would it be ok to print the source code of your Functions so I can reproduce the problem?

Thanks.

@satyarohith
Copy link
Author

Hi @ehmicky,

Sorry for taking this long. I couldn’t reproduce this anymore so I’m closing this issue for now. I’ll re-open it if I encounter this issue again.

Thanks. :)

@Rich-Harris
Copy link

More information for anyone else who lands here after googling for the text of the error: #68

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug code to address defects in shipped code
Projects
None yet
Development

No branches or pull requests

3 participants