Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot Find Turbo module v1.2.9 with Github Actions #1263

Closed
alfergus0n opened this issue May 18, 2022 · 13 comments
Closed

Cannot Find Turbo module v1.2.9 with Github Actions #1263

alfergus0n opened this issue May 18, 2022 · 13 comments

Comments

@alfergus0n
Copy link

alfergus0n commented May 18, 2022

What version of Turborepo are you using?

1.2.9

What package manager are you using / does the bug impact?

npm

What operating system are you using?

Linux

Describe the Bug

When using Turbo v1.2.9 with Github Actions, i get:

npm ERR! Error: Cannot find module 'turbo

I revert back to 1.2.5, and it works fine as expected.

Expected Behavior

For turbo 1.2.9 to be found and used while using Github Actions.

To Reproduce

Simply use v1.2.9 in a npm package.json, turbo isn't found when installing using:

npm ci

if you wanna see: https://github.com/alfergus0n/whatever/runs/6497062661?check_suite_focus=true

bare bones project, i'm only using it to test run turbo.

Here is it working with 1.2.5, same exact setup in essence: https://github.com/alfergus0n/whatever/actions/runs/2348214585

edit: Also seems to work with 1.2.8 just fine, just tested.

@markhughes
Copy link

@ryanlewis
Copy link

ryanlewis commented May 19, 2022

Hi, experienced a similar problem. I don't have a repro or a series of actions I can share I'm afraid, but the error experienced in an npm install action is the same as the stacktrace/error log in #820

Temporarily reverted to 1.2.8, which is working fine for me as well.

@alfergus0n
Copy link
Author

alfergus0n commented May 19, 2022

I had set it to private, my bad. it's public now, should be accessible now @markhughes

@ryanlewis
Copy link

Weird - 1.2.8 stopped working for me today, but bumping to 1.2.9 works now? 😕

@markhughes
Copy link

      - name: Install dependencies if node_modules cache not found
        if: steps.cache-modules.outputs.cache-hit != 'true'
        run: npm ci

Is it possible that you already have a cache in place and its not installing turbo? Try removing this step or try again now (as I assume the cache has expired) - you could change this so it will always run if your lock file changes

@alfergus0n
Copy link
Author

alfergus0n commented May 23, 2022

      - name: Install dependencies if node_modules cache not found
        if: steps.cache-modules.outputs.cache-hit != 'true'
        run: npm ci

Is it possible that you already have a cache in place and its not installing turbo? Try removing this step or try again now (as I assume the cache has expired) - you could change this so it will always run if your lock file changes

Impossible I think, since turbo would then be installed within the cached modules

Plus it said this when it attempted to retrieve cache:

Cache not found for input keys, implying that npm CI will run because cache is not found for node_modules.. It's in the log for that specific action run that i linked, so it didn't find the cache explicitly

it also shows that it is running npm ci explicitly in the next step after (same action that i linked)

Having that said, it is now mysteriously working, similarly to @ryanlewis. So no idea what was going on or what recently changed but now it is. Maybe it was some caching issue on github's end or something, where this version just wasn't available yet since it recently came out. anyway closing. thank you.

@markhughes
Copy link

I was referring to perhaps before (as you had the branch set to master -> main -> master) so perhaps it got cached on a branch without the dependency?

I might be wrong, would be cool to find the issue though! good luck :)

@iOvergaard
Copy link

This happens every once in a while for me as well. The solution is always the same: set the version in package.json to something else (it doesn't matter what).

It might be cache related, but honestly didn't have enough insight to investigate. I'm running the setup-node@v3 action with caching enabled and then npm ci like so:

- name: Use Node.js ${{ matrix.node-version }}
  uses: actions/setup-node@v3
  with:
    node-version: ${{ matrix.node-version }}
    cache: 'npm'

- run: npm ci

@alfergus0n
Copy link
Author

could be related to this #1749

@alfergus0n
Copy link
Author

but yes, changing the version (as in the version of Turborepo), makes it work magically. Which isn't a legitimate solution, just a quirky fix. unfortunately

@alfergus0n
Copy link
Author

alfergus0n commented Sep 23, 2022

Ok, I figured it out on my end:

So for whatever reason, when doing some sort of action related to the package-lock.json (when it automatically updates based on npm actions, such as npm install etc, it was removing critical fields such as "resolved" and "integrity":

    "node_modules/turbo-linux-64": {
      "version": "1.2.16",
      "resolved": "https://registry.npmjs.org/turbo-linux-64/-/turbo-linux-64-1.2.16.tgz",
      "integrity": "sha512-q6gtdMWCzM0Sktkd73zcaQjNoeM1MjtrbwQBctWN/Sgj0eiPBPnzpIvokvx98x7RLf4qyI99/mlme0Dn5fx21A==",
      "cpu": [
        "x64"
      ],
      "dev": true,
      "optional": true,
      "os": [
        "linux"
      ]
    },

This seems to be the actual culprit. Why it behaves this way, I have little to no insight. But that is what seems to be causing this missing turbo in whatever environment, in my case it was Linux. Note: i was not touching turbo repo at all when this occurred. In fact, i was developing a native module for React Native. Somehow or another package-lock.json was altered in that process and it removed those two critical fields, not just for Linux but for other environments as well i noticed.

Something to keep in mind. I will in the future be aware of any turbo related changes in the lock, even when I'm not doing anything to turbo. Specifically those two fields.

@davecarlson
Copy link

davecarlson commented Oct 10, 2022

This is happening to me too.
My package.json:

"devDependencies": {
    "turbo": "^1.5.1"
  },

My github action:

strategy:
      matrix:
        os: [ubuntu-latest]

steps: 
- name: Setup Node.js environment
   uses: actions/setup-node@v3
   with:
     node-version: 16

- name: Install dependencies
   run: npm install 

Error :

npm ERR! [turbo] Failed to find package "turbo-linux-64" on the file system
npm ERR! 
npm ERR! This can happen if you use the "--no-optional" flag. The "optionalDependencies"
npm ERR! package.json feature is used by turbo to install the correct binary executable
npm ERR! for your current platform. This install script will now attempt to work around
npm ERR! this. If that fails, you need to remove the "--no-optional" flag to use turbo.
npm ERR! 
npm ERR! node:internal/modules/cjs/loader:956
npm ERR!   const err = new Error(message);
npm ERR!               ^
npm ERR! 
npm ERR! Error: Cannot find module 'turbo'
npm ERR! Require stack:
npm ERR! - /home/runner/work/MYTHING/node_modules/turbo/node-platform.js
npm ERR! - /home/runner/work/MYTHING/node_modules/turbo/install.js
npm ERR!     at Function.Module._resolveFilename (node:internal/modules/cjs/loader:956:15)
npm ERR!     at Function.resolve (node:internal/modules/cjs/helpers:108:[19](https://github.com/MYTHING/actions/runs/3220577540/jobs/5267453195#step:6:20))
npm ERR!     at downloadedBinPath (/home/runner/work/MYTHING/node_modules/turbo/node-platform.js:44:44)
npm ERR!     at checkAndPreparePackage (/home/runner/work/MYTHING/node_modules/turbo/install.js:277:15)
npm ERR!     at Object.<anonymous> (/home/runner/work/MYTHING/node_modules/turbo/install.js:302:1)
npm ERR!     at Module._compile (node:internal/modules/cjs/loader:11[26](https://github.com/MYTHING/actions/runs/3220577540/jobs/5267453195#step:6:27):14)
npm ERR!     at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
npm ERR!     at Module.load (node:internal/modules/cjs/loader:1004:[32](https://github.com/MYTHING/actions/runs/3220577540/jobs/5267453195#step:6:33))
npm ERR!     at Function.Module._load (node:internal/modules/cjs/loader:8[39](https://github.com/MYTHING/actions/runs/3220577540/jobs/5267453195#step:6:40):12)
npm ERR!     at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
npm ERR!   code: 'MODULE_NOT_FOUND',

The only fix is to delete my package-lock and not commit it.

FYI, it happens with by npm install and npm ci

@alfergus0n
Copy link
Author

alfergus0n commented Nov 22, 2022

Which makes sense. For those who don't have the option of not committing a package-lock, as I mentioned, just pay close attention to the resolved field for turbo repo before committing the lock. If it's missing, simply undo the change and make sure you set the correct version (a simple npm install turbo@x.x.x --save-dev would likely suffice). Same result as above, you just get to commit/keep your lock.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants