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

pnpm i in workspace throws a type error in pnpm.cjs as it can't read property 'manifest' of undefined on windows #4904

Closed
sebastiangug opened this issue Jun 20, 2022 · 7 comments
Milestone

Comments

@sebastiangug
Copy link

sebastiangug commented Jun 20, 2022

pnpm version:

I've switched between multiple versions and they all cause this, so it makes me think the culprit is something else and that pnpm workspaces don't work well on windows machines.

Code to reproduce the issue:

pnpm i -w=super-server --reporter ndjson @nestjs/graphql

Actual behavior:

{"time":1655762783630,"hostname":"owlee","pid":20084,"level":"debug","name":"pnpm:scope","selected":1,"workspacePrefix":"D:\\00 software\\fercula\\fercula"}
{"time":1655762783673,"hostname":"owlee","pid":20084,"level":"error","name":"pnpm","name":"pnpm","err":{"name":"pnpm","message":"Cannot read properties of undefined (reading 'manifest')","stack":"pnpm: Cannot read properties of undefined (reading 'manifest')\n    at C:\\Users\\Seb\\AppData\\Roaming\\npm\\node_modules\\pnpm\\dist\\pnpm.cjs:122747:49\n    at Array.map (<anonymous>)\n    at C:\\Users\\Seb\\AppData\\Roaming\\npm\\node_modules\\pnpm\\dist\\pnpm.cjs:122744:39\n    at Array.map (<anonymous>)\n    at getImporters (C:\\Users\\Seb\\AppData\\Roaming\\npm\\node_modules\\pnpm\\dist\\pnpm.cjs:122740:34)\n    at recursive (C:\\Users\\Seb\\AppData\\Roaming\\npm\\node_modules\\pnpm\\dist\\pnpm.cjs:122762:31)\n    at async handler (C:\\Users\\Seb\\AppData\\Roaming\\npm\\node_modules\\pnpm\\dist\\pnpm.cjs:123155:11)\n    at async C:\\Users\\Seb\\AppData\\Roaming\\npm\\node_modules\\pnpm\\dist\\pnpm.cjs:187855:21\n    at async run (C:\\Users\\Seb\\AppData\\Roaming\\npm\\node_modules\\pnpm\\dist\\pnpm.cjs:187829:34)\n    at async runPnpm (C:\\Users\\Seb\\AppData\\Roaming\\npm\\node_modules\\pnpm\\dist\\pnpm.cjs:188047:5)"}}

Additional information:

  • node -v prints:
    node v: 16.15.1
    npm v: 8.12.2
    pnpm version: 7.3.0

I have just now manually cleaned up all my app data, node, npm, pnpm, roaming data, program files as well as environment variables, did a reboot and installed everything from scratch.

Error persists.

The error occurs in this recursive function which I copied from the line of code mentioned in the error:

      async function getImporters() {
        const importers = [];
        await Promise.all(chunks.map(async (prefixes, buildIndex) => {
          if (opts.ignoredPackages != null) {
            prefixes = prefixes.filter((prefix) => !opts.ignoredPackages.has(prefix));
          }
          return Promise.all(prefixes.map(async (prefix) => {
            importers.push({
              buildIndex,
              manifest: manifestsByPath[prefix].manifest,
              rootDir: prefix
            });
          }));
        }));
        return importers;
      }

If I on-the-spot-dirty change that to use safe null accessing, the next error is thrown about the manifest:

{"time":1655763314110,"hostname":"owlee","pid":22292,"level":"debug","name":"pnpm:scope","selected":1,"workspacePrefix":"D:\\00 software\\fercula\\fercula"}
{"time":1655763314155,"hostname":"owlee","pid":22292,"level":"error","name":"pnpm","name":"pnpm","err":{"name":"pnpm","message":"Cannot destructure property 'manifest' of 'manifestsByPath[rootDir]' as it is undefined.","stack":"pnpm: Cannot destructure property 'manifest' of 'manifestsByPath[rootDir]' as it is undefined.\n    at C:\\Users\\Seb\\AppData\\Roaming\\npm\\node_modules\\pnpm\\dist\\pnpm.cjs:122785:19\n    at async Promise.all (index 0)\n    at async recursive (C:\\Users\\Seb\\AppData\\Roaming\\npm\\node_modules\\pnpm\\dist\\pnpm.cjs:122782:9)\n    at async handler (C:\\Users\\Seb\\AppData\\Roaming\\npm\\node_modules\\pnpm\\dist\\pnpm.cjs:123155:11)\n    at async C:\\Users\\Seb\\AppData\\Roaming\\npm\\node_modules\\pnpm\\dist\\pnpm.cjs:187855:21\n    at async run (C:\\Users\\Seb\\AppData\\Roaming\\npm\\node_modules\\pnpm\\dist\\pnpm.cjs:187829:34)\n    at async runPnpm (C:\\Users\\Seb\\AppData\\Roaming\\npm\\node_modules\\pnpm\\dist\\pnpm.cjs:188047:5)\n    at async C:\\Users\\Seb\\AppData\\Roaming\\npm\\node_modules\\pnpm\\dist\\pnpm.cjs:188039:7"}}

non verbose second error:

 ERROR  Cannot destructure property 'manifest' of 'manifestsByPath[rootDir]' as it is undefined.

that manifest assignemnt it's trying to assign the manifest property of an object that does not exist, throwing that type error, my guess is the manifestsByPath[prefix] isn't resolved properly for windows paths?

Not sure where to look in the source code fo this though.

@unlight
Copy link

unlight commented Jun 26, 2022

Is this fixed?
I'm still getting such error with pnpm 7.3.0 and also in 7.4.0-1

@zkochan
Copy link
Member

zkochan commented Jun 26, 2022

Well, it was not yet published.

@chandantiwari1
Copy link

I am getting the same error. What's the solution for this.
 ERROR  Cannot read properties of undefined (reading 'manifest')

@eberridge
Copy link

I am getting the same error. What's the solution for this.  ERROR  Cannot read properties of undefined (reading 'manifest')

I just had a similar error and it was a bear to debug. I ended up adding some console output to the 'getAllProjects' function in pnpm.cjs to see what was going wrong. Turns out that my CMD custom startup command sets the CWD to "c:\blah..." whereas the code in getAllProjects has a dictionary that tries to resolve stuff to "C:\blah...". Make sure your CWD starts with upper-case C:

@aiguoli
Copy link

aiguoli commented Feb 13, 2023

I meet the same error, solved temporarily by running cmd in vscode

@menasheh
Copy link

menasheh commented May 9, 2023

Same error in v8.4.0. Using cmd does not resolve.

@zkochan
Copy link
Member

zkochan commented May 10, 2023

Done one more fix in this PR: #6525

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

No branches or pull requests

7 participants