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.

Package does not work as a library

See original GitHub issue

Steps to reproduce the problem:

  • npm init a project on node 4.3.2
  • npm i --save-dev contentful-export
contentful-export@1.0.4 node_modules/contentful-export
├── json-stringify-safe@5.0.1
├── bluebird@3.4.1
├── npmlog@2.0.4 (ansi@0.3.1, gauge@1.2.7, are-we-there-yet@1.1.2)
├── yargs@4.8.1 (decamelize@1.2.0, y18n@3.2.1, lodash.assign@4.1.0, which-module@1.0.0, set-blocking@2.0.0, require-main-filename@1.0.1, window-size@0.2.0, require-directory@2.1.1, get-caller-file@1.0.1, yargs-parser@2.4.1, os-locale@1.4.0, cliui@3.2.0, string-width@1.0.1, read-pkg-up@1.0.1)
├── lodash@4.14.0
└── contentful-batch-libs@4.0.13 (contentful-management@1.1.9, contentful@3.5.0, babel-runtime@6.11.6) 

Then run the following code:

const spaceExport = require('contentful-export')

const options = {
  spaceId: 'a_valid_space_id',
  managementToken: 'a_valid_mgmnt_token',
};

spaceExport(options)
  .then((output) => {
    console.log('space data', output)
  })
  .catch((err) => {
    console.log('oh no! errors occurred!', err)
  })

Throws the following error:

/exporter/node_modules/contentful-export/node_modules/contentful-batch-libs/utils/create-clients.js:34
    spaceId: opts.sourceSpace
                 ^

TypeError: Cannot read property 'sourceSpace' of undefined
    at createClients (exporter/node_modules/contentful-export/node_modules/contentful-batch-libs/utils/create-clients.js:34:18)
    at runContentfulExport (exporter/node_modules/contentful-export/dist/run-contentful-export.js:41:45)
    at Object.<anonymous> (exporter/index.js:9:1)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Function.Module.runMain (module.js:441:10)
    at startup (node.js:134:18)
    at node.js:962:3

Using the same SPACE_ID and MANAGEMENT_TOKEN in the CLI works correctly.

My use case is I’d like to create automatic backup AWS Lambdas to backup my Contentful spaces, and the CLI tool is not an option in this context.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Khaledgarbayacommented, Jul 27, 2016

hi @eisenbergrobin let me take a look and get back to you asap

0reactions
Khaledgarbayacommented, Jul 27, 2016

Read more comments on GitHub >

github_iconTop Results From Across the Web

R not finding package even after package installation
go to this folder C:\Users\hp\Documents\R\win-library\4.0 in your PC. And delete '00LOCK' named folder. then It will work properly, ...
Read more >
R Studio Package Installation Not Recognized - General
When I try to run a package, R says that there is no package with the name ... It looks like the library...
Read more >
swift-package-manager/Usage.md at main - GitHub
A library package contains code which other packages can use and depend on. To get started, create a directory and run swift package...
Read more >
R Installation and Administration - 6 Add-on packages
A package is loaded from a library by the function library() . Thus a library is a directory containing installed packages; the main...
Read more >
Upgrading R: package compatibility issues - Amazon AWS
When this happens, the problem is obvious: when R code calls library() ... Sometimes packages installed with a previous version of R will...
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