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

Getting error on start: internal/modules/cjs/loader.js:638 throw err; #7568

Closed
theQureshi opened this issue Apr 14, 2020 · 29 comments
Closed
Labels
question user / developer questions

Comments

@theQureshi
Copy link

theQureshi commented Apr 14, 2020

Description

I am building an IDE on Theia for a month now and it's working completely fine until three days ago when my Theia application just wouldn't start. It builds normally, but it doesn't start.

yarn start:browser and yarn start:electron both are having issues.

Screen Shot 2020-04-14 at 4 57 05 PM

Reproduction Steps

To reproduce, please follow these steps:

  1. Clone Theia repo
  2. Run yarn
  3. Run yarn start:browser or yarn start:electron

Versions:

Node: v10.20.1
NVM: 0.35.3
NPM: 6.14.4
OS: macOS Catalina 10.15.4 (19E287) [latest]

Solutions already done

I have tried every single solution that I found on the internet regarding this issue. I also uninstalled and installed Node and NVM twice. But that didn't help.

@vince-fugnitto
Copy link
Member

@theQureshi please see if the following changes solve your issue?

@vince-fugnitto vince-fugnitto added the question user / developer questions label Apr 14, 2020
@kittaakos
Copy link
Contributor

I have tried every single solution that I found on the internet regarding this issue. I also uninstalled and installed Node and NVM twice. But that didn't help.

@theQureshi, please use resolutions as a temporary workaround in the package.json as suggested here:

  "resolutions": {
    "**/**/nsfw": "1.2.7"
   },

Closing.

@theQureshi
Copy link
Author

theQureshi commented Apr 14, 2020

@theQureshi please see if the following changes solve your issue?

@vince-fugnitto tried but the issue is still there.

@vince-fugnitto
Copy link
Member

@theQureshi please see if the following changes solve your issue?

@vince-fugnitto tried but the issue is still there.

When trying, did you also update the yarn.lock? If not, I suspect it's pinning an older version.

@theQureshi
Copy link
Author

I have tried every single solution that I found on the internet regarding this issue. I also uninstalled and installed Node and NVM twice. But that didn't help.

@theQureshi, please use resolutions as a temporary workaround in the package.json as suggested here:

  "resolutions": {
    "**/**/nsfw": "1.2.7"
   },

Closing.

@kittaakos this didn't help mate!

@theQureshi
Copy link
Author

theQureshi commented Apr 14, 2020

@theQureshi please see if the following changes solve your issue?

@vince-fugnitto tried but the issue is still there.

When trying, did you also update the yarn.lock? If not, I suspect it's pinning an older version.

Yes I updated yarn.lock and packages/core/package.json both files

@kittaakos
Copy link
Contributor

@kittaakos this didn't help mate!

Did you do this in your main package.json?

@theQureshi
Copy link
Author

@kittaakos this didn't help mate!

Did you do this in your main package.json?

Yes!

@kittaakos
Copy link
Contributor

Do you have code to share?

@theQureshi
Copy link
Author

theQureshi commented Apr 14, 2020

package.json file after applying fixed suggested here.

{
  "private": true,
  "name": "@theia/monorepo",
  "version": "0.0.0",
  "engines": {
    "yarn": "1.0.x || >=1.2.1",
    "node": ">=10.11.0 <12"
  },
  "resolutions": {
    "**/**/nsfw": "1.2.7",
    "**/@types/node": "~10.3.6",
    "**/vscode-json-languageserver/**/vscode-languageserver": "6.0.0-next.1"
  },
  "devDependencies": {
    "@types/chai-string": "^1.4.0",
    "@types/jsdom": "^11.0.4",
    "@types/node": "~10.3.6",
    "@types/sinon": "^2.3.5",
    "@types/temp": "^0.8.29",
    "@types/uuid": "^3.4.3",
    "@typescript-eslint/eslint-plugin": "^2.16.0",
    "@typescript-eslint/eslint-plugin-tslint": "^2.16.0",
    "@typescript-eslint/parser": "^2.16.0",
    "chai-string": "^1.4.0",
    "colors": "^1.4.0",
    "concurrently": "^3.5.0",
    "electron-mocha": "^8.2.0",
    "eslint": "^6.8.0",
    "eslint-plugin-import": "^2.20.0",
    "eslint-plugin-no-null": "^1.0.2",
    "ignore-styles": "^5.0.1",
    "jsdom": "^11.5.1",
    "lerna": "^2.2.0",
    "nyc": "^15.0.0",
    "rimraf": "^2.6.1",
    "sinon": "^3.3.0",
    "temp": "^0.8.3",
    "tslint": "^5.12.0",
    "typedoc": "^0.15.0-0",
    "typedoc-plugin-external-module-map": "^1.0.0",
    "typescript": "~3.5.3",
    "uuid": "^3.2.1"
  },
  "scripts": {
    "preinstall": "node-gyp install",
    "postinstall": "node scripts/post-install.js",
    "prepare": "yarn prepare:travis && yarn prepare:references && yarn prepare:build && yarn prepare:hoisting && yarn download:plugins",
    "prepare:travis": "node scripts/prepare-travis.js",
    "prepare:references": "node scripts/compile-references.js",
    "prepare:build": "yarn build && run lint && run build \"@theia/example-*\" --stream --parallel",
    "prepare:hoisting": "theia check:hoisted -s",
    "clean": "yarn lint:clean && node scripts/run-reverse-topo.js yarn clean",
    "build": "tsc -b configs/root-compilation.tsconfig.json --verbose",
    "watch": "tsc -b configs/root-compilation.tsconfig.json -w",
    "lint": "run lint",
    "lint:clean": "rimraf .eslintcache",
    "lint:oneshot": "node --max-old-space-size=4096 node_modules/eslint/bin/eslint.js --cache=true \"{dev-packages,packages,examples}/**/*.{ts,tsx}\"",
    "docs": "rimraf gh-pages/docs/next && typedoc --tsconfig configs/typedoc-tsconfig.json --options configs/typedoc.json",
    "test": "yarn test:references && yarn test:theia && yarn test:electron && yarn test:browser",
    "test:references": "node scripts/compile-references --dry-run",
    "test:theia": "run test \"@theia/!(example-)*\" --stream --concurrency=1",
    "test:browser": "yarn rebuild:browser && run test \"@theia/example-browser\"",
    "test:electron": "yarn rebuild:electron && run test \"@theia/example-electron\"",
    "rebuild:clean": "rimraf .browser_modules",
    "rebuild:browser": "theia rebuild:browser",
    "rebuild:electron": "theia rebuild:electron",
    "rebuild:electron:debug": "DEBUG=electron-rebuild && yarn rebuild:electron",
    "publish": "yarn && yarn test && yarn publish:latest",
    "publish:latest": "lerna publish && yarn publish:check",
    "publish:next": "yarn next:publish && yarn next:publish --skip-npm && yarn publish:check",
    "next:publish": "lerna publish --exact --canary=next --npm-tag=next --yes",
    "publish:check": "node scripts/check-publish.js",
    "start:browser": "yarn rebuild:browser && yarn --cwd examples/browser start",
    "start:electron": "yarn rebuild:electron && yarn --cwd examples/electron start",
    "download:plugins": "theia download:plugins"
  },
  "workspaces": [
    "dev-packages/*",
    "packages/*",
    "examples/*"
  ],
  "theiaPluginsDir": "plugins",
  "theiaPlugins": {
    "vscode-builtin-bat": "http://open-vsx.org/api/vscode/bat/1.39.1/file/vscode.bat-1.39.1.vsix",
    "vscode-builtin-clojure": "http://open-vsx.org/api/vscode/clojure/1.39.1/file/vscode.clojure-1.39.1.vsix",
    "vscode-builtin-coffeescript": "http://open-vsx.org/api/vscode/coffeescript/1.39.1/file/vscode.coffeescript-1.39.1.vsix",
    "vscode-builtin-configuration-editing": "http://open-vsx.org/api/vscode/configuration-editing/1.39.1/file/vscode.configuration-editing-1.39.1.vsix",
    "vscode-builtin-cpp": "http://open-vsx.org/api/vscode/cpp/1.39.1/file/vscode.cpp-1.39.1.vsix",
    "vscode-builtin-csharp": "http://open-vsx.org/api/vscode/csharp/1.39.1/file/vscode.csharp-1.39.1.vsix",
    "vscode-builtin-css": "http://open-vsx.org/api/vscode/css/1.39.1/file/vscode.css-1.39.1.vsix",
    "vscode-builtin-debug-auto-launch": "http://open-vsx.org/api/vscode/debug-auto-launch/1.39.1/file/vscode.debug-auto-launch-1.39.1.vsix",
    "vscode-builtin-docker": "http://open-vsx.org/api/vscode/docker/1.39.1/file/vscode.docker-1.39.1.vsix",
    "vscode-builtin-emmet": "http://open-vsx.org/api/vscode/emmet/1.39.1/file/vscode.emmet-1.39.1.vsix",
    "vscode-builtin-fsharp": "http://open-vsx.org/api/vscode/fsharp/1.39.1/file/vscode.fsharp-1.39.1.vsix",
    "vscode-builtin-go": "http://open-vsx.org/api/vscode/go/1.39.1/file/vscode.go-1.39.1.vsix",
    "vscode-builtin-groovy": "http://open-vsx.org/api/vscode/groovy/1.39.1/file/vscode.groovy-1.39.1.vsix",
    "vscode-builtin-grunt": "http://open-vsx.org/api/vscode/grunt/1.39.1/file/vscode.grunt-1.39.1.vsix",
    "vscode-builtin-gulp": "http://open-vsx.org/api/vscode/gulp/1.39.1/file/vscode.gulp-1.39.1.vsix",
    "vscode-builtin-handlebars": "http://open-vsx.org/api/vscode/handlebars/1.39.1/file/vscode.handlebars-1.39.1.vsix",
    "vscode-builtin-hlsl": "http://open-vsx.org/api/vscode/hlsl/1.39.1/file/vscode.hlsl-1.39.1.vsix",
    "vscode-builtin-html": "http://open-vsx.org/api/vscode/html/1.39.1/file/vscode.html-1.39.1.vsix",
    "vscode-builtin-ini": "http://open-vsx.org/api/vscode/ini/1.39.1/file/vscode.ini-1.39.1.vsix",
    "vscode-builtin-jake": "http://open-vsx.org/api/vscode/jake/1.39.1/file/vscode.jake-1.39.1.vsix",
    "vscode-builtin-java": "http://open-vsx.org/api/vscode/java/1.39.1/file/vscode.java-1.39.1.vsix",
    "vscode-builtin-javascript": "http://open-vsx.org/api/vscode/javascript/1.39.1/file/vscode.javascript-1.39.1.vsix",
    "vscode-builtin-json": "http://open-vsx.org/api/vscode/json/1.39.1/file/vscode.json-1.39.1.vsix",
    "vscode-builtin-less": "http://open-vsx.org/api/vscode/less/1.39.1/file/vscode.less-1.39.1.vsix",
    "vscode-builtin-log": "http://open-vsx.org/api/vscode/log/1.39.1/file/vscode.log-1.39.1.vsix",
    "vscode-builtin-lua": "http://open-vsx.org/api/vscode/lua/1.39.1/file/vscode.lua-1.39.1.vsix",
    "vscode-builtin-make": "http://open-vsx.org/api/vscode/make/1.39.1/file/vscode.make-1.39.1.vsix",
    "vscode-builtin-markdown": "http://open-vsx.org/api/vscode/markdown/1.39.1/file/vscode.markdown-1.39.1.vsix",
    "vscode-builtin-markdown-language-features": "http://open-vsx.org/api/vscode/markdown-language-features/1.39.1/file/vscode.markdown-language-features-1.39.1.vsix",
    "vscode-builtin-merge-conflict": "http://open-vsx.org/api/vscode/merge-conflict/1.39.1/file/vscode.merge-conflict-1.39.1.vsix",
    "vscode-builtin-npm": "http://open-vsx.org/api/vscode/npm/1.39.1/file/vscode.npm-1.39.1.vsix",
    "vscode-builtin-node-debug": "http://open-vsx.org/api/ms-vscode/node-debug/1.44.2/file/ms-vscode.node-debug-1.44.2.vsix",
    "vscode-builtin-node-debug2": "http://open-vsx.org/api/ms-vscode/node-debug2/1.33.0/file/ms-vscode.node-debug2-1.33.0.vsix",
    "vscode-builtin-objective-c": "http://open-vsx.org/api/vscode/objective-c/1.39.1/file/vscode.objective-c-1.39.1.vsix",
    "vscode-builtin-perl": "http://open-vsx.org/api/vscode/perl/1.39.1/file/vscode.perl-1.39.1.vsix",
    "vscode-builtin-powershell": "http://open-vsx.org/api/vscode/powershell/1.39.1/file/vscode.powershell-1.39.1.vsix",
    "vscode-builtin-pug": "http://open-vsx.org/api/vscode/pug/1.39.1/file/vscode.pug-1.39.1.vsix",
    "vscode-builtin-python": "http://open-vsx.org/api/vscode/python/1.39.1/file/vscode.python-1.39.1.vsix",
    "vscode-builtin-r": "http://open-vsx.org/api/vscode/r/1.39.1/file/vscode.r-1.39.1.vsix",
    "vscode-builtin-razor": "http://open-vsx.org/api/vscode/razor/1.39.1/file/vscode.razor-1.39.1.vsix",
    "vscode-builtin-ruby": "http://open-vsx.org/api/vscode/ruby/1.39.1/file/vscode.ruby-1.39.1.vsix",
    "vscode-builtin-rust": "http://open-vsx.org/api/vscode/rust/1.39.1/file/vscode.rust-1.39.1.vsix",
    "vscode-builtin-scss": "http://open-vsx.org/api/vscode/scss/1.39.1/file/vscode.scss-1.39.1.vsix",
    "vscode-builtin-shaderlab": "http://open-vsx.org/api/vscode/shaderlab/1.39.1/file/vscode.shaderlab-1.39.1.vsix",
    "vscode-builtin-shellscript": "http://open-vsx.org/api/vscode/shellscript/1.39.1/file/vscode.shellscript-1.39.1.vsix",
    "vscode-builtin-sql": "http://open-vsx.org/api/vscode/sql/1.39.1/file/vscode.sql-1.39.1.vsix",
    "vscode-builtin-swift": "http://open-vsx.org/api/vscode/swift/1.39.1/file/vscode.swift-1.39.1.vsix",
    "vscode-builtin-theme-abyss": "http://open-vsx.org/api/vscode/theme-abyss/1.39.1/file/vscode.theme-abyss-1.39.1.vsix",
    "vscode-builtin-theme-defaults": "http://open-vsx.org/api/vscode/theme-defaults/1.39.1/file/vscode.theme-defaults-1.39.1.vsix",
    "vscode-builtin-theme-kimbie-dark": "http://open-vsx.org/api/vscode/theme-kimbie-dark/1.39.1/file/vscode.theme-kimbie-dark-1.39.1.vsix",
    "vscode-builtin-theme-monokai": "http://open-vsx.org/api/vscode/theme-monokai/1.39.1/file/vscode.theme-monokai-1.39.1.vsix",
    "vscode-builtin-theme-monokai-dimmed": "http://open-vsx.org/api/vscode/theme-monokai-dimmed/1.39.1/file/vscode.theme-monokai-dimmed-1.39.1.vsix",
    "vscode-builtin-theme-quietlight": "http://open-vsx.org/api/vscode/theme-quietlight/1.39.1/file/vscode.theme-quietlight-1.39.1.vsix",
    "vscode-builtin-theme-red": "http://open-vsx.org/api/vscode/theme-red/1.39.1/file/vscode.theme-red-1.39.1.vsix",
    "vscode-builtin-theme-solarized-dark": "http://open-vsx.org/api/vscode/theme-solarized-dark/1.39.1/file/vscode.theme-solarized-dark-1.39.1.vsix",
    "vscode-builtin-theme-tomorrow-night-blue": "http://open-vsx.org/api/vscode/theme-tomorrow-night-blue/1.39.1/file/vscode.theme-tomorrow-night-blue-1.39.1.vsix",
    "vscode-builtin-typescript": "http://open-vsx.org/api/vscode/typescript/1.39.1/file/vscode.typescript-1.39.1.vsix",
    "vscode-builtin-typescript-language-features": "http://open-vsx.org/api/vscode/typescript-language-features/1.39.1/file/vscode.typescript-language-features-1.39.1.vsix",
    "vscode-builtin-vb": "http://open-vsx.org/api/vscode/vb/1.39.1/file/vscode.vb-1.39.1.vsix",
    "vscode-builtin-icon-theme-seti": "http://open-vsx.org/api/vscode/vscode-theme-seti/1.39.1/file/vscode.vscode-theme-seti-1.39.1.vsix",
    "vscode-builtin-xml": "http://open-vsx.org/api/vscode/xml/1.39.1/file/vscode.xml-1.39.1.vsix",
    "vscode-builtin-yaml": "http://open-vsx.org/api/vscode/yaml/1.39.1/file/vscode.yaml-1.39.1.vsix",
    "vscode-editorconfig": "https://open-vsx.org/api/EditorConfig/EditorConfig/0.14.4/file/EditorConfig.EditorConfig-0.14.4.vsix",
    "vscode-eslint": "http://open-vsx.org/api/dbaeumer/vscode-eslint/2.1.1/file/dbaeumer.vscode-eslint-2.1.1.vsix",
    "vscode-references-view": "http://open-vsx.org/api/ms-vscode/references-view/0.0.47/file/ms-vscode.references-view-0.0.47.vsix"
  }
}

@vince-fugnitto
Copy link
Member

@theQureshi please try a clean (git clean -fdx), and rebuild when applying the resolutions block?

@kittaakos
Copy link
Contributor

What does your "postinstall": "node scripts/post-install.js", do?

@kittaakos
Copy link
Contributor

@theQureshi, I cannot do much with the package.json you have attached. I still believe you have the same issue as described in #7510, but maybe I am wrong.

I am reopening for better visibility; maybe someone knows the fix.

@kittaakos kittaakos reopened this Apr 14, 2020
@vince-fugnitto
Copy link
Member

@theQureshi, I cannot do much with the package.json you have attached. I still believe you have the same issue as described in #7510, but maybe I am wrong.

I believe it's the package.json from the root of the repo?
I think his issue mentioned he was unable to build the main repo from sources.

@akosyakov
Copy link
Member

Pinning nsfw should not be necessary, latest version 1.2.9 is good. Could you share the repo?

@theQureshi
Copy link
Author

theQureshi commented Apr 15, 2020

@theQureshi please try a clean (git clean -fdx), and rebuild when applying the resolutions block?

I am testing things out by just downloading the .zip from eclipse-theia/theia repo. So git clean doesn't apply to me. Or does it?

@theQureshi
Copy link
Author

What does your "postinstall": "node scripts/post-install.js", do?

I am not sure what that does. I just got my package.json from eclipse-theia/theia master repo.

@theQureshi
Copy link
Author

@theQureshi, I cannot do much with the package.json you have attached. I still believe you have the same issue as described in #7510, but maybe I am wrong.

I went through the issue you mentioned and tried the solution suggested there. No luck.

I am reopening for better visibility; maybe someone knows the fix.

Thanks 👍

@theQureshi
Copy link
Author

theQureshi commented Apr 15, 2020

I believe it's the package.json from the root of the repo?

@vince-fugnitto yes, this is from the root of the repo.

I think his issue mentioned he was unable to build the main repo from sources.

I didn't quite get it.

@theQureshi
Copy link
Author

Could you share the repo?

@akosyakov I just downloaded .zip from eclipse-theia/theia master repo and didn't make any changes except for the changes suggested here.

@vince-fugnitto
Copy link
Member

If not already done so, can you make sure that you have the necessary prerequisites installed?

@theQureshi
Copy link
Author

@vince-fugnitto I just went through the prerequisites and I have double checked that I have installed everything required on my system.

However, it was mentioned that Node v10.15.3 is preferred so I downgraded from 10.22.1 using NVM.

Doing so had no effect on the error except one thing. The number changed from 638 to 584. Previously, I was getting internal/modules/cjs/loader.js:638 throw err; and now I am getting internal/modules/cjs/loader.js:584 throw err;

@carrierlian
Copy link

I meet this thing,internal/modules/cjs/loader.js:638 ,how to solve it?

@iyermobile
Copy link

rm -rf node_modules package-lock.json && npm install && npm start

@Jagveer-Loky-cko
Copy link

rm -rf node_modules package-lock.json && npm install && npm start

I still see the errors while I'm running this above command.

electron@2.0.18 postinstall /root/merchant-api/test/Gateway.IntegrationTests/node_modules/electron
node install.js

internal/modules/cjs/loader.js:638
throw err;

@vince-fugnitto
Copy link
Member

rm -rf node_modules package-lock.json && npm install && npm start

I still see the errors while I'm running this above command.

electron@2.0.18 postinstall /root/merchant-api/test/Gateway.IntegrationTests/node_modules/electron
node install.js

internal/modules/cjs/loader.js:638
throw err;

@Jagveer-Loky-cko you shouldn't be using npm install, can you confirm it's what you are doing?

@Jagveer-Loky-cko
Copy link

rm -rf node_modules package-lock.json && npm install && npm start

I still see the errors while I'm running this above command.

electron@2.0.18 postinstall /root/merchant-api/test/Gateway.IntegrationTests/node_modules/electron
node install.js

internal/modules/cjs/loader.js:638
throw err;

@Jagveer-Loky-cko you shouldn't be using npm install, can you confirm it's what you are doing?

I have succeeded in troubleshooting it.
It works fine now.

rm -rf /root/package-lock-.json
npm install

After that, I run the npm audit, I found 4 vulnerabilities and fixed it.

Thanks guys !

@jittygitty
Copy link

jittygitty commented Dec 3, 2022

Did this ever get solved??

Everywhere I google, it seems "nobody" has any clue what is causing such errors. The ONLY advice I ever see is well just remove this uninstall reinstall, i've done just about all the suggestions from a gazillion different links and still same error. I guess with node/javascript you have to be one of the core developers of the engine to actually have any clue what's going on? I'm on fresh install of Debian.

/Theia/theia-1.32.0/examples/browser$ yarn start
yarn run v1.22.19
$ yarn -s rebuild && theia start --plugins=local-dir:../../plugins
native node modules are already rebuilt for browser
node:internal/modules/cjs/loader:998
throw err;
^
Error: Cannot find module '/home/user/Theia/theia-1.32.0/examples/browser/src-gen/backend/main.js'
at Module._resolveFilename (node:internal/modules/cjs/loader:995:15)
at Module._load (node:internal/modules/cjs/loader:841:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:23:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
Node.js v18.12.1
Done in 2.50s.

And yes, there's no src-gen folder in there, apparently yarn install did not create it although it finished successfully.

UPDATE: solved see #11947

@msujew
Copy link
Member

msujew commented Dec 3, 2022

Since the original poster had their issue resolved, I will close this.

@msujew msujew closed this as completed Dec 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question user / developer questions
Projects
None yet
Development

No branches or pull requests

9 participants