stackblitz / webcontainer-core

Dev environments. In your web app.
https://webcontainers.io
MIT License
3.89k stars 161 forks source link

BUG: Unable to run the Nx CLI in WebContainers #137

Closed sebastiandg7 closed 1 year ago

sebastiandg7 commented 3 years ago

Describe the bug:

The Nx CLI is not able to properly run inside a WebContainer. The error seems to be related with the perf_hooks package.

Link to the blitz that caused the error https://stackblitz.com/edit/nx-workspace-empty

Steps to reproduce:

  1. Go to the terminal
  2. Run npm run nx list
  3. See error:
❯ npm run nx list
TypeError: y is not a function
    at Object.mark (https://nx-workspace-empty.jw.staticblitz.com/blitz.57be275669708b1d42e233d60c80159bef577631.js:6:1330286)
    at Object.initLocal (/projects/nx-workspace-empty/node_modules/@nrwl/cli/lib/init-local.js:15:30)
    at Object.eval (/projects/nx-workspace-empty/node_modules/@nrwl/cli/bin/nx.js:42:18)
    at Object.function (https://nx-workspace-empty.jw.staticblitz.com/blitz.57be275669708b1d42e233d60c80159bef577631.js:11:20499)
    at Module._compile (https://nx-workspace-empty.jw.staticblitz.com/blitz.57be275669708b1d42e233d60c80159bef577631.js:6:187549)
    at Object.Module._extensions..js (https://nx-workspace-empty.jw.staticblitz.com/blitz.57be275669708b1d42e233d60c80159bef577631.js:6:187908)
    at Module.load (https://nx-workspace-empty.jw.staticblitz.com/blitz.57be275669708b1d42e233d60c80159bef577631.js:6:185988)
    at Function.Module._load (https://nx-workspace-empty.jw.staticblitz.com/blitz.57be275669708b1d42e233d60c80159bef577631.js:6:183564)
    at Function.executeUserEntryPoint [as runMain] (https://nx-workspace-empty.jw.staticblitz.com/blitz.57be275669708b1d42e233d60c80159bef577631.js:6:794697)
    at Object.a0_0x2054 (https://nx-workspace-empty.jw.staticblitz.com/blitz.57be275669708b1d42e233d60c80159bef577631.js:6:1395283)

Expected behavior:

The CLI should run and give an output similar to this:

Click to expand ``` npm run nx list > myorg@0.0.0 nx > nx "list" > NX Installed plugins: @nrwl/jest (builders,generators) @nrwl/linter (builders) @nrwl/workspace (builders,generators) > NX Also available: @nrwl/angular (generators) @nrwl/cypress (executors,generators) @nrwl/express (executors,generators) @nrwl/nest (executors,generators) @nrwl/next (executors,generators) @nrwl/node (executors,generators) @nrwl/nx-plugin (executors,generators) @nrwl/react (executors,generators) @nrwl/storybook (executors,generators) @nrwl/web (executors,generators) > NX Community plugins: nx-electron - An Nx plugin for developing Electron applications nx-stylelint - Nx plugin to use stylelint in a nx workspace @nxtend/ionic-react - An Nx plugin for developing Ionic React applications and libraries @nxtend/ionic-angular - An Nx plugin for developing Ionic Angular applications and libraries @nxtend/capacitor - An Nx plugin for developing cross-platform applications using Capacitor @nxtend/firebase - An Nx plugin for developing applications using Firebase @angular-architects/ddd - Nx plugin for structuring a monorepo with domains and layers @offeringsolutions/nx-karma-to-jest - Nx plugin for replacing karma with jest in an Nx workspace @flowaccount/nx-serverless - Nx plugin for node/angular-universal schematics and deployment builders in an Nx workspace @ns3/nx-serverless - Nx plugin for node serverless applications in an Nx workspace @ns3/nx-jest-playwright - Nx plugin to run jest-playwright e2e tests in an Nx workspace @dev-thought/nx-deploy-it - Nx plugin to deploy applications on your favorite cloud provider @offeringsolutions/nx-protractor-to-cypress - Nx plugin to replace protractor with cypress in an nx workspace @nx-tools/nx-docker - Nx plugin to build docker images of your affected apps @angular-custom-builders/lite-serve - Nx plugin to run the e2e test on an existing dist folder @nx-plus/nuxt - Nx plugin adding first class support for Nuxt in your Nx workspace. @nx-plus/vue - Nx plugin adding first class support for Vue in your Nx workspace. @nx-plus/docusaurus - Nx plugin adding first class support for Docusaurus in your Nx workspace. @twittwer/compodoc - Nx Plugin to integrate the generation of documentation with Compodoc in the Nx workflow @nxext/svelte - Nx plugin to use Svelte within nx workspaces @nxext/stencil - Nx plugin to use StencilJs within nx workspaces @joelcode/gcp-function - Nx plugin to generate, test, lint, build, serve, & deploy Google Cloud Function @nx-go/nx-go - Nx plugin to use Go in a Nx workspace @angular-architects/module-federation - Nx plugin to use webpack module federation @nxrocks/nx-spring-boot - Nx plugin to generate, run, package, build (and more) Spring Boot projects inside your Nx workspace @trumbitta/nx-plugin-openapi - OpenAPI Plugin for Nx. Keep your API spec files in libs, and auto-generate sources. @nxrocks/nx-flutter - Nx Plugin adding first class support for Flutter in your Nx workspace @srleecode/domain - Nx Plugin for allowing operations to occur at the domain level instead of the default library level @jscutlery/semver - Nx plugin to automate semantic versioning and CHANGELOG generation. ngx-deploy-npm - Publish your libraries to NPM with just one command. @trafilea/nx-shopify - Nx plugin for developing performance-first Shopify themes nx-dotnet - Nx plugin for developing and housing .NET projects within an Nx workspace. @nxrocks/nx-quarkus - Nx plugin to generate, run, package, build (and more) Quarkus projects inside your Nx workspace @nx-extend/translations - Nx plugin to extract, pull, push and translate your apps translations > NX NOTE Use "nx list [plugin]" to find out more ```

Version of webcontainer: Hash: 57be275669708b1d42e233d60c80159bef577631

Screenshots:

Desktop (please complete the following information): Browser name = Chrome Full version = 91.0.4472.77 Major version = 91 navigator.appName = Netscape navigator.userAgent = Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36 performance.memory = { "totalJSHeapSize": 79671752, "usedJSHeapSize": 73199176, "jsHeapSizeLimit": 4294705152 }

Additional context:

The error can be reproduced by running perf_hooks separately. See this example: https://stackblitz.com/edit/node-9zsb4r

SamVerschueren commented 3 years ago

@sebastiandg7 Thanks for trying out Nx and reporting this back to us. This seems like an issue on our end and I created an internal ticket for it.

d3lm commented 1 year ago

Hey 👋 I think this should no longer be an issue because missing perf_hooks APIs have been implemented. I am going to close this. If you run into more problems with this, please file a new issue.