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

Uncaught Error: Cannot find module 'react' when using npm 5.3.0 #787

Closed
onmyway133 opened this Issue Jan 10, 2018 · 14 comments

Comments

Projects
None yet
4 participants
@onmyway133

onmyway133 commented Jan 10, 2018

Hi, I was using electron-packager in my app https://github.com/onmyway133/PushNotifications and it was working fine. Now I want to make new release, but all I get is

Uncaught Error: Cannot find module 'react'
    at Module._resolveFilename (module.js:470:15)
    at Function.Module._resolveFilename (/Users/khoa/XcodeProject2/PushNotifications/PushNotifications-darwin-x64/Pu…tions.app/Contents/Resources/electron.asar/common/reset-search-paths.js:35:12)
    at Function.Module._load (module.js:418:25)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/khoa/XcodeProject2/PushNotifications/PushNotifications-darwin-x64/PushNotifications.app/Contents/Resources/app/renderer.js:2:15)
    at Object.<anonymous> (/Users/khoa/XcodeProject2/PushNotifications/PushNotifications-darwin-x64/PushNotifications.app/Contents/Resources/app/renderer.js:16:3)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)

I don't know if this is a duplicate of #517, but I can't find an answer from that thread.

When I run (with yarn start), it is working fine. When I run yarn release, it just shows a blank app with the above error. I tried upgrade react, electron, ... but still the problem. Here is my package.json https://github.com/onmyway133/PushNotifications/blob/master/package.json

My environment

  • Node v8.4.0
  • macOS 10.13.2
@welcome

This comment has been minimized.

welcome bot commented Jan 10, 2018

👋 Thanks for opening your first issue here! If you have a question about using Electron Packager, read the support docs. If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. Development and issue triage is community-driven, so please be patient and we will get back to you as soon as we can.

To help make it easier for us to investigate your issue, please follow the contributing guidelines.

@MarshallOfSound

This comment has been minimized.

Member

MarshallOfSound commented Jan 10, 2018

Try upgrading yarn (what version are you running now)

@onmyway133

This comment has been minimized.

onmyway133 commented Jan 10, 2018

@MarshallOfSound Hi, this problem happens before and after I update yarn. My current version is v1.3.2

@malept malept added the needs info label Jan 10, 2018

@malept

This comment has been minimized.

Member

malept commented Jan 10, 2018

I can't reproduce this on Linux. When I run the packaged app, I get the same screen as in the screenshot in your repo's README. Here's how I did it:

$ git clone https://github.com/onmyway133/PushNotifications
$ cd PushNotifications
$ yarn
$ yarn run release
$ PushNotifications-linux-x64/PushNotifications

My yarn is also at 1.3.2.

Can you try with a fresh git checkout of your repo?

@onmyway133

This comment has been minimized.

onmyway133 commented Jan 11, 2018

@malept I tried a fresh git clone, and still the problem 😢

@no-response no-response bot removed the needs info label Jan 11, 2018

@malept

This comment has been minimized.

Member

malept commented Jan 11, 2018

Can you try building on another computer or in a Linux VM? I'm concerned that your environment is incorrectly configured somehow.

@malept malept added the needs info label Jan 11, 2018

@pixelkritzel

This comment has been minimized.

pixelkritzel commented Jan 12, 2018

I had this problem with another dependency. I kind of solved by using npm@3 instead of npm@5. It seems there is a bug in npm@5 prune command

@malept

This comment has been minimized.

Member

malept commented Jan 12, 2018

@pixelkritzel this issue is a yarn specific bug.

@pixelkritzel

This comment has been minimized.

pixelkritzel commented Jan 12, 2018

Sorry, my bad.

@malept malept changed the title from Uncaught Error: Cannot find module 'react' to Uncaught Error: Cannot find module 'react' when using yarn Jan 12, 2018

@onmyway133

This comment has been minimized.

onmyway133 commented Jan 17, 2018

@malept I tried running npm run release but still the problem. So it shouldn't be because of yarn ?

@no-response no-response bot removed the needs info label Jan 17, 2018

@onmyway133

This comment has been minimized.

onmyway133 commented Jan 17, 2018

When I run in debug mode DEBUG=electron-packager npm run release, I get


> PushNotifications@1.2.2 release /Users/khoa/XcodeProject2/PushNotifications
> electron-packager . --icon=Icon/Icon.icns

  electron-packager Electron Packager 10.1.1 +0ms
  electron-packager Node v8.4.0 +2ms
  electron-packager Host Operating system: darwin (x64) +0ms
  electron-packager Packager Options: {"_":["."],"all":false,"deref-symlinks":true,"derefSymlinks":true,"download":{"strictSSL":true},"overwrite":false,"prune":true,"quiet":false,"icon":"Icon/Icon.icns","dir":".","protocols":[]} +0ms
  electron-packager Target Platforms: darwin +0ms
  electron-packager Target Architectures: x64 +0ms
  electron-packager Inferring application name from productName in /Users/khoa/XcodeProject2/PushNotifications/package.json +0ms
  electron-packager Inferring appVersion from version in /Users/khoa/XcodeProject2/PushNotifications/package.json +0ms
  electron-packager Inferring target Electron version from electron in /Users/khoa/XcodeProject2/PushNotifications/package.json +11ms
  electron-packager Application name: PushNotifications +23ms
  electron-packager Target Electron version: 1.7.10 +0ms
  electron-packager Ignored path regular expressions: [ '/node_modules/electron($|/)',
  '/node_modules/electron-prebuilt(-compile)?($|/)',
  '/node_modules/electron-packager($|/)',
  '/\\.git($|/)',
  '/node_modules/\\.bin($|/)',
  '\\.o(bj)?$' ] +0ms
  electron-packager Downloading Electron with options {"strictSSL":true,"platform":"darwin","arch":"x64","version":"1.7.10"} +0ms
Packaging app for platform darwin x64 using electron v1.7.10
  electron-packager Creating /var/folders/wq/4p3h9g5d4v53gkz0k7xl11dr0000gn/T/electron-packager/darwin-x64-template +227ms
  electron-packager Extracting /Users/khoa/.electron/electron-v1.7.10-darwin-x64.zip to /var/folders/wq/4p3h9g5d4v53gkz0k7xl11dr0000gn/T/electron-packager/darwin-x64-template +0ms
  electron-packager Initializing app in /var/folders/wq/4p3h9g5d4v53gkz0k7xl11dr0000gn/T/electron-packager/darwin-x64/PushNotifications-darwin-x64 from /var/folders/wq/4p3h9g5d4v53gkz0k7xl11dr0000gn/T/electron-packager/darwin-x64-template template +0ms
  electron-packager Ignored paths based on the out param: [ '/Users/khoa/XcodeProject2/PushNotifications/PushNotifications-darwin-x64',
  '/Users/khoa/XcodeProject2/PushNotifications/PushNotifications-linux-ia32',
  '/Users/khoa/XcodeProject2/PushNotifications/PushNotifications-linux-x64',
  '/Users/khoa/XcodeProject2/PushNotifications/PushNotifications-linux-armv7l',
  '/Users/khoa/XcodeProject2/PushNotifications/PushNotifications-linux-arm64',
  '/Users/khoa/XcodeProject2/PushNotifications/PushNotifications-mas-x64',
  '/Users/khoa/XcodeProject2/PushNotifications/PushNotifications-win32-ia32',
  '/Users/khoa/XcodeProject2/PushNotifications/PushNotifications-win32-x64' ] +2s
  electron-packager Pruning modules via: npm prune --production +0ms
Command failed: npm prune --production
npm ERR! May not delete: /private/var/folders/wq/4p3h9g5d4v53gkz0k7xl11dr0000gn/T/electron-packager/darwin-x64/PushNotifications-darwin-x64/Electron.app/Contents/Resources/app/node_modules/.bin

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/khoa/.npm/_logs/2018-01-17T14_43_41_288Z-debug.log

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! PushNotifications@1.2.2 release: `electron-packager . --icon=Icon/Icon.icns`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the PushNotifications@1.2.2 release script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/khoa/.npm/_logs/2018-01-17T14_43_41_339Z-debug.log

It says

Command failed: npm prune --production

So maybe it's related to #686

@onmyway133

This comment has been minimized.

onmyway133 commented Jan 17, 2018

Here is my story onmyway133/blog#145. Hope it helps someone

@onmyway133 onmyway133 closed this Jan 17, 2018

@malept malept changed the title from Uncaught Error: Cannot find module 'react' when using yarn to Uncaught Error: Cannot find module 'react' when using npm 5.3.0 Jan 17, 2018

@onmyway133

This comment has been minimized.

onmyway133 commented Feb 9, 2018

I think I get this same problem, but on Linux build onmyway133/IconGenerator#4. Any help would be appreciated

@malept

This comment has been minimized.

Member

malept commented Feb 9, 2018

Try using --no-package-manager.

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