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.

Use one, track level, package.json

See original GitHub issue

I realize this was proposed previously (#235) and closed as wontfix, but there is a simple and correct way to have a single install of all the necessary tools. The only necessary package.json change would be to the scripts section.

Right now we have a package.json in each exercise with a scripts section as follows:

"scripts": {
  "test": "jest --no-cache ./*",
  "watch": "jest --no-cache --watch ./*",
  "lint": "eslint .",
  "lint-test": "eslint . && jest --no-cache ./* "
},

All package.json files should be removed from the exercise directories, and a single package.json would be added to the track directory. The scripts section of it should be changed to the following:

"scripts": {
  "test": "jest --no-cache",
  "watch": "jest --no-cache --watch",
  "lint": "eslint --ignore-pattern '*.spec.js'"
},

The usage is changed very slightly.

Running npm test or npm run lint would test and lint, respectively, all exercises. To test or lint a single particular exercise, simply append -- <exercise-name>.

So, for example, if I wanted to test the simple-cipher exercise I would run npm test -- simple-cipher.

I tested this on MacOS and Linux, and it works correctly. I haven’t tested it on Windows, but my understanding is that it should work the same way.

I didn’t begin with a pull request, although I’d be happy to do so, because I wanted to get feedback and hopefully buy-in before proceeding.

Thanks for reading. Looking forward to your thoughts.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:4
  • Comments:17 (14 by maintainers)

github_iconTop GitHub Comments

4reactions
bdjnkcommented, Jul 1, 2018

@matthewmorgan There are two reasons doing this helps the end-users.

As an end-user myself, I was put off by having to reinstall identical node_modules in each exercise. So much so I took the time to solve the problem for myself and propose it here. Others may have the same irritation, and indeed, friends I’ve directed to this track have mentioned it.

More importantly, part of what we’re trying to teach is the right way to structure code, and for ECMAScript that very much includes, or should include, the tools, as they’re fundamental to the experience in the real world.

1reaction
SleeplessBytecommented, Dec 21, 2021

Hi @chrissygonzalez , yes! That works, but still requires the outside-of-the-exercise “setup” 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Use Node.js Modules with npm and package.json
To demonstrate this, move up a level in your directory tree and create a new folder named cloned_locator in the same directory level...
Read more >
package-lock.json - npm Docs
Describe a single representation of a dependency tree such that teammates, deployments, and continuous integration are guaranteed to install exactly the same ...
Read more >
Equivalent of `package.json' and `package-lock.json` for `pip`
json to specify 'top-level' dependencies, and create a lock-file to keep track of the specific versions of all packages (i.e. top-level and sub ......
Read more >
Move into a single package.json · Issue #76412 · elastic/kibana
The proposal is to use a single top level package.json (in the kibana folder) to manage all the dependencies we need in the...
Read more >
Using Node.js Modules with npm and package.json: A Tutorial
In this cloud tutorial, we will walk you through the detailed steps of using Node.js modules with npm and package.json. Node.js is an...
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