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.

Pull version information from package.json, running `npm run build` produces unwanted changes

See original GitHub issue

Hi @thomasrockhu!

I was going to create a pull request for this, but in my local setup when I run npm i followed by npm run build I get many spurious unrelated changes in dist/index.js, mostly a diff that starts with var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { and goes on from there, many times in the file. I tried this in two separate machines and have had the issue on both… Not sure if your machine setup is different and is picking up a different component version? Anyways, maybe take a look at whether you need to update some component in package.json or similar to ensure generation of dist/index.js is consistent.

The suggestion I was going to make is:

diff --git a/src/buildExec.ts b/src/buildExec.ts
index edb614f..2dbf0a4 100644
--- a/src/buildExec.ts
+++ b/src/buildExec.ts
@@ -1,7 +1,7 @@
 const core = require('@actions/core');
 const github = require('@actions/github');
-import VERSION from './version';
+const pjson = require('../package.json');
 const context = github.context;
@@ -59,7 +59,7 @@ const buildExec = () => {
-      `github-action-${VERSION}`,
+      `github-action-v${pjson.version}`,
   const options:any = {};

Which reads the “version” field from package.json, so you could remove src/version.ts altogether and keep the version string in a single place. (BTW, I found this suggestion in this StackOverflow answer.)

Feel free to push a commit with this change if you like the idea. Or let me know if you manage to figure out if something was missing in package.json to make generation consistent and I can send a PR then.

Cheers! Filipe

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:18 (14 by maintainers)

github_iconTop GitHub Comments

RA80533commented, Jun 11, 2021

Can you try to remove the node_modules folder and run installation again? npm takes into account the shape of the node_modules folder when trying to determine what to install. In other words, it’s behavior is partially determined by node_modules. You want a fresh installation at every point you can get.

RA80533commented, Jun 11, 2021
rm -rf node_modules
npm install

Additionally, please update your distribution of both Node.js and npm. v12.18.4 contains unpatched vulnerabilities.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is there a way to get version from package.json in nodejs code?
json file namely using pkginfo module. require('pkginfo')(module, 'version'); And your package variables will be set to module.
Read more >
package.json - npm Docs
json are the name and version fields as they will be required. The name and version together form an identifier that is assumed...
Read more >
Missing modules when running npm run build or npm install
Hi, I am working on a foundation press project and I am trying to get it all setup and working. I have cloned...
Read more >
npm run build - YouTube
Ben Monro talk will cover the ins and outs of building a javascript project using nothing but npm ...
Read more >
Creating an Npm-Only Build Step for JavaScript — the Easy Way
Let's Build an Npm-only Script · Run a node server that watches for file changes · Compile Sass to CSS and revision the...
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 Post

No results found

github_iconTop Related Hashnode Post

No results found