Shopify/node-themekit

`ENOENT @shopify/themekit/bin/theme`

anulman opened this issue · 2 comments

Problem

I am trying to deploy node-themekit with several developers on my team. However, they are getting the following error when trying to run our build script — and I can't reproduce it!

Error: spawn /Users/username/shopify-theme/node_modules/@shopify/themekit/bin/theme ENOENT

We are not using slate-tools or slate.

Replication steps

I haven't the foggiest; it works on my machine!

More Information

Here is the very lightweight build script we are using (a starting point as we implement version control + more frontend tooling):

# bin/build.js
import program from 'commander';
import themekit from '@shopify/themekit';

program
  // option `env`
  .option('-e, --env', 'shopify environment', 'development')
  // option `build`
  .option('-b, --build', 'build app w/ webpack', true)
  .option('--no-build', 'don\'t build app w/ webpack')
  // option `deploy`
  .option('-d, --deploy', 'deploy to shopify once built', true)
  .option('--no-deploy', 'don\'t deploy to shopify once built')
  // option `open`
  .option('-o, --open', 'open once built', true)
  .option('--no-open', 'don\'t open once built')
  // option `watch`
  .option('-w, --watch', 'watch the build for updates', true)
  .option('--no-watch', 'don\'t watch the build for updates')
  // option `cwd`
  .option('--cwd <dir>', 'working directory for themekit commands', './dist')
  .parse(process.argv);

const { cwd, env, deploy, open, watch } = program;
const password = process.env.SHOPIFY_APP_PASSWORD;
const themeid = process.env.SHOPIFY_THEME_ID;
const store = process.env.SHOPIFY_STORE;

const baseFlags = { env, password, store, themeid };
const options = { cwd };

const main = async function() {
  if (deploy) {
    await themekit.command('deploy', baseFlags, options);
  }

  if (watch) {
    themekit.command('watch', baseFlags, options);
  }

  if (open) {
    await themekit.command('open', baseFlags, options);
  }
};

main()
  .then(console.log)
  .catch(console.error);

We are calling this via yarn run start, a shortcut to babel-node -r dotenv/config -- bin/build.js and getting the error above. All developers are using Node 12.14.1.

[Edited to add: to add to the weirdness, machines that are erroring can still execute the binary at /Users/username/shopify-theme/node_modules/@shopify/themekit/bin/theme !]

Resolved! The passed cwd did not exist on others' machines, as part of the build system is still in flux + we gitignored the dir.

That said, I will let y'alls decide whether to close this issue as I think the error message could have been a lot more helpful. For example, when passed nonexistent dir foo, the CLI outputs invalid project directory lstat foo: no such file or directory

(Much thanks @jacojoubert for the assist <3)