flexn-io / renative

🚀🚀🚀 Unified Development Platform for iOS, tvOS, Android, Android TV, Android Wear, Web, Tizen TV, Tizen Watch, Tizen Mobile, LG webOS, macOS/OSX, Windows, KaiOS, FirefoxOS Firefox TV platforms
https://renative.org
MIT License
1.82k stars 180 forks source link

Cannot build when using yarn - webpack.js not found #593

Closed EyMaddis closed 1 year ago

EyMaddis commented 4 years ago

Describe the bug The same problem described in https://github.com/pavjacko/renative/issues/585 is still a problem when building via rnv build

This time it is webpack itself.

Cannot find module '/my/path/smarttv-platforms/node_modules/rnv/node_modules/webpack/bin/webpack.js'

Expected behavior App should build.

Screenshots or copy&paste

❯ ./node_modules/.bin/rnv build -p tizen

┌──────────────────────────────────────────────────────────────────────────────┐
│                                                                              │
│        ██████╗ ███████╗███╗   ██╗ █████╗ ████████╗██╗██╗   ██╗███████╗       │
│        ██╔══██╗██╔════╝████╗  ██║██╔══██╗╚══██╔══╝██║██║   ██║██╔════╝       │
│        ██████╔╝█████╗  ██╔██╗ ██║███████║   ██║   ██║██║   ██║█████╗         │
│        ██╔══██╗██╔══╝  ██║╚██╗██║██╔══██║   ██║   ██║╚██╗ ██╔╝██╔══╝         │
│        ██║  ██║███████╗██║ ╚████║██║  ██║   ██║   ██║ ╚████╔╝ ███████╗       │
│        ╚═╝  ╚═╝╚══════╝╚═╝  ╚═══╝╚═╝  ╚═╝   ╚═╝   ╚═╝  ╚═══╝  ╚══════╝       │
│                                                                              │
│        Version: 0.31.0                                                       │
│        https://renative.org                                                  │
│        🚀 Firing up!...                                                      │
│        $ rnv build -p tizen                                                  │
│        Start Time: 10/13/2020, 6:11:03 PM                                    │
│                                                                              │
└──────────────────────────────────────────────────────────────────────────────┘

[ task ] registerEngines[1]
[ task ] configureRuntimeDefaults[1] appId:null
[ task ] checkAndMigrateProject[1]
[ task ] parseRenativeConfigs[1]
[ task ] getWorkspaceDirPath[1]
[ task ] loadPluginTemplates[1]
[ task ] _parsePluginTemplateDependencies[1] scope:root
[ task ] loadEngines[1]
[ task ] _generatePlatformTemplatePaths[1]
[ info ] Current Engine: engine-rn-web
[ task ] initializeTask[1] build
[ task ] => [build]
[ task ] [build] checkIfProjectAndNodeModulesExists[1]
[ hook ] [build] executePipe ('build:before')
[ task ] [build] taskRnvBuild[1] parent:null
[ task ] => [build] => [package]
[ hook ] [package] executePipe ('package:before')
[ task ] [package] taskRnvPackage[1] parent:build
[ task ] => [package] => [configure]
[ hook ] [configure] executePipe ('configure:before')
[ task ] [configure] taskRnvConfigure[1]
[ task ] => [configure] => [platform configure]
[ hook ] [platform configure] executePipe ('platform:configure:before')
[ task ] [platform configure] taskRnvPlatformConfigure[1] 
[ task ] => [platform configure] => [project configure]
[ hook ] [project configure] executePipe ('project:configure:before')
[ task ] [project configure] taskRnvProjectConfigure[1]
[ task ] [project configure] checkAndMigrateProject[2]
[ task ] [project configure] parseRenativeConfigs[2]
[ task ] [project configure] getWorkspaceDirPath[2]
[ task ] [project configure] loadPluginTemplates[2]
[ task ] [project configure] _parsePluginTemplateDependencies[2] scope:root
[ task ] [project configure] loadEngines[2]
[ task ] [project configure] _generatePlatformTemplatePaths[2]
[ task ] [project configure] checkAndCreateProjectPackage[1]
[ task ] => [project configure] => [workspace configure]
[ task ] [workspace configure] taskRnvWorkspaceConfigure[1]
[ task ] <= [project configure] <= workspace configure
[ task ] [project configure] checkIfTemplateConfigured[1]
[ task ] => [project configure] => [install]
[ hook ] [install] executePipe ('install:before')
[ task ] [install] taskRnvInstall[1] requiresInstall:false:true
[ hook ] [install] executePipe ('install:after')
[ task ] <= [project configure] <= install
[ task ] [project configure] checkCrypto[1]
[ task ] [project configure] configureRuntimeDefaults[2] appId:blank
[ task ] [project configure] applyTemplate[1] renative-template-blank=>undefined
[ task ] [project configure] _applyTemplate[1] current:renative-template-blank selected:undefined
[ task ] [project configure] configureRuntimeDefaults[3] appId:blank
[ task ] => [project configure] => [install]
[ hook ] [install] executePipe ('install:before')
[ task ] [install] taskRnvInstall[2] requiresInstall:false:true
[ hook ] [install] executePipe ('install:after')
[ task ] <= [project configure] <= install
[ task ] => [project configure] => [app configure]
[ hook ] [app configure] executePipe ('app:configure:before')
[ task ] [app configure] taskRnvAppConfigure[1]
[ task ] [app configure] listAppConfigsFoldersSync[1] ignoreHiddenConfigs:true
[ task ] [app configure] parseRenativeConfigs[3]
[ task ] [app configure] generateBuildConfig[1] size:122.88 KB
[ task ] [app configure] getWorkspaceDirPath[3]
[ task ] [app configure] generateBuildConfig[2] size:122.88 KB
[ task ] [app configure] generateBuildConfig[3] size:122.88 KB
[ task ] [app configure] loadPluginTemplates[3]
[ task ] [app configure] _parsePluginTemplateDependencies[3] scope:root
[ task ] [app configure] loadEngines[3]
[ task ] [app configure] generateBuildConfig[4] size:122.88 KB
[ task ] [app configure] _generatePlatformTemplatePaths[3]
[ task ] [app configure] generateBuildConfig[5] size:123.54 KB
[ task ] [app configure] generateBuildConfig[6] size:123.54 KB
[ task ] [app configure] getWorkspaceDirPath[4]
[ task ] [app configure] generateBuildConfig[7] size:123.54 KB
[ task ] [app configure] generateLocalConfig[1] resetAppId:false
[ task ] [app configure] generateBuildConfig[8] size:123.54 KB
[ info ] [app configure] Current App Config: blank
[ hook ] [app configure] executePipe ('app:configure:after')
[ task ] <= [project configure] <= app configure
[ task ] [project configure] resolvePluginDependants[1]
[ task ] [project configure] configurePlugins[1]
[ task ] [project configure] versionCheck[1]
[ task ] [project configure] versionCheck:rnvRunner:0.31.0,rnvProject:0.31.0[1]
[ task ] [project configure] configureRuntimeDefaults[4] appId:blank
[ task ] [project configure] copyRuntimeAssets[1]
[ task ] [project configure] parseFonts[1]
[ task ] [project configure] configureTemplateFiles[1]
[ task ] [project configure] fixRenativeConfigsSync[1]
[ task ] [project configure] checkAndCreateGitignore[1]
[ task ] [project configure] configureEntryPoints[1]
[ warn ] [project configure] Extra platform android will be ignored because it's not configured in your ./renative.json: { defaults.supportedPlatforms } object.
[ warn ] [project configure] Extra platform androidwear will be ignored because it's not configured in your ./renative.json: { defaults.supportedPlatforms } object.
[ warn ] [project configure] Extra platform androidtv will be ignored because it's not configured in your ./renative.json: { defaults.supportedPlatforms } object.
[ task ] [project configure] generateRuntimeConfig[1]
[ task ] [project configure] overrideTemplatePlugins[1]
[ task ] [project configure] parsePlugins[1]
[ hook ] [project configure] executePipe ('project:configure:after')
[ task ] <= [platform configure] <= project configure
[ task ] [platform configure] isPlatformSupported[1]
[ task ] [platform configure] checkAndConfigureSdks[1]
[ task ] [platform configure] checkAndConfigureTizenSdks:tizen[1]
[ task ] [platform configure] isBuildSchemeSupported[1]
[ info ] [platform configure] Current Build Scheme: debug
[ task ] [platform configure] checkSdk[1]
[ task ] [platform configure] _isSdkInstalled[1]
[ task ] [platform configure] configureRuntimeDefaults[5] appId:blank
[ task ] => [platform configure] => [install]
[ hook ] [install] executePipe ('install:before')
[ task ] [install] taskRnvInstall[3] requiresInstall:false:true
[ hook ] [install] executePipe ('install:after')
[ task ] <= [platform configure] <= install
[ task ] [platform configure] [1] taskRnvPlatformConfigure hasBuildFolderPresent:true
[ task ] [platform configure] createPlatformBuild[1]
[ task ] [platform configure] injectPlatformDependencies[1]
[ hook ] [platform configure] executePipe ('platform:configure:after')
[ task ] <= [configure] <= platform configure
[ task ] [configure] copySharedPlatforms[1]
[ task ] [configure] configureTizenProject[1]
[ task ] [configure] configureTizenGlobal[1]
[ task ] [configure] copyAssetsFolder[1]
[ task ] [configure] configureCoreWebProject[1]
[ task ] [configure] _generateWebpackConfigs[1]
[ task ] [configure] parsePlugins[2]
[ task ] [configure] configureProject[1]
[ task ] [configure] copyBuildsFolder[1]
[ task ] [configure] copyTemplatePluginsSync[1] (./platformBuilds/blank_tizen)
[ task ] [configure] parsePlugins[3]
[ hook ] [configure] executePipe ('configure:after')
[ task ] <= [package] <= configure
[ hook ] [package] executePipe ('package:after')
[ task ] <= [build] <= package
[ task ] [build] buildTizenProject[1]
[ task ] [build] buildWeb[1]
✖ FAILED: npx cross-env PLATFORM=tizen NODE_ENV=production  node /my/path/smarttv-platforms/node_modules/rnv/node_modules/webpack/bin/webpack.js -p --config ./platformBuilds/blank_tizen/webpack.config.prod.js
┌──────────────────────────────────────────────────────────────────────────────┐
│  🚀  SUMMARY | 10/13/2020, 6:11:04 PM                                        │
│  $ rnv build -p tizen                                                        │
├──────────────────────────────────────────────────────────────────────────────┤
│  ReNative Version: 0.31.0                                                    │
│  Project Name ($package.name): smarttv-platforms                             │
│  Project Version ($package.version): 0.1.0                                   │
│  Workspace ($.workspaceID): rnv                                              │
│  Platform (-p): tizen                                                        │
│  Engine ($.platforms.tizen.engine): engine-rn-web                            │
│  App Config (-c): blank                                                      │
│  Build Scheme (-s): debug                                                    │
│  Target (-t): T-samsung-5.5-x86                                              │
│  Supported Platforms: tizen                                                  │
│  Env Info: darwin | x64 | node v10.21.0                                      │
│  Executed Time: 0h:0m:0s:587ms                                               │
│                                                                              │
│ [ warn ] [project configure] Extra platform android will be ignored because it's not configured in your ./renative.json: { defaults.supportedPlatforms } object.
│ [ warn ] [project configure] Extra platform androidwear will be ignored because it's not configured in your ./renative.json: { defaults.supportedPlatforms } object.
│ [ warn ] [project configure] Extra platform androidtv will be ignored because it's not configured in your ./renative.json: { defaults.supportedPlatforms } object.
│ [ error ] [build] COMMAND: 

npx cross-env PLATFORM=tizen NODE_ENV=production  node /my/path/smarttv-platforms/node_modules/rnv/node_modules/webpack/bin/webpack.js -p --config ./platformBuilds/blank_tizen/webpack.config.prod.js 

FAILED with ERROR: 

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

Error: Cannot find module '/my/path/smarttv-platforms/node_modules/rnv/node_modules/webpack/bin/webpack.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
│                                                                              │
│  Project location:                                                           │
│  ./platformBuilds/blank_tizen/project                                        │
└──────────────────────────────────────────────────────────────────────────────┘

Desktop (please complete the following information):

Additional context Renative Project is within a subdirectory of another yarn project.

EyMaddis commented 4 years ago

@pavjacko So I hackily replace the webpack path with doResolve('webpack'), now it builds, but the for -p tizen it builds the appShell, not the real app. The platformBuilds/blank_tizen/project/build directory does not contain any .js files, just the appShell. However, platformBuilds/blank_tizen/server/ contains everything html/js related, but not the config.xml and other tizen specific files.

image

mihaiblaga89 commented 4 years ago

@EyMaddis that's correct behavior. In order to provide hot reloads for tizen the appShell is being installed on the device/emu. It's nothing more than a small little website which redirects to the webpack's url upon launch. Webpack should build your app and serve it with webpack-dev-server, rnv will inject the url into appShell and install it on the TV. After 5s of launching the appShell you should see your app.

EyMaddis commented 4 years ago

@mihaiblaga89 For development yes but I meant release builds. Tizen does not support export or deploy, so I assume that rnv build -p tizen should build a production release bundle. I also tried setting the env NODE_ENV=production.

Am I missing something? I cannot find anything else in the documentation to create a release .wgt file.

EDIT: I found it after digging through the code: rnv build -p tizen -s release with renative.json:

    "tizen": {
      "buildSchemes": {
        "debug": {
          "bundleAssets": false
        },
        "release": {
          "bundleAssets": true
        }
      }
    },
alaingoga commented 3 years ago

@EyMaddis where did you add doResolve('webpack') I'm having the same issue when using the local rnv package yarn rnv build -p ... instead of global:

Error: Cannot find module '......./node_modules/rnv/node_modules/webpack/bin/webpack.js'

EyMaddis commented 3 years ago

@alaingoga Of the top of my head it was the sdk-webpack.js file and I just changed it manually for the build, if I remember correctly

alaingoga commented 3 years ago

Thanks @EyMaddis I found where webpack is called: https://github.com/pavjacko/renative/blob/release/0.31/packages/rnv/src/sdk-webpack/index.js#L258

Also why it works for rnv run and its because there is an alternative here: https://github.com/pavjacko/renative/blob/release/0.31/packages/rnv/src/sdk-webpack/index.js#L485

Root cause of the problem is that in local RNV_NODE_MODULES_DIR is pointing to /node_modules/rnv/node_modules/ instead of where the app is and is living so /node_modules/webpack/bin/webpack.js. Can be resolved.

https://github.com/pavjacko/renative/blob/release/0.31/packages/rnv/src/core/constants.js#L8

I wonder why?

alaingoga commented 3 years ago

By changing:

export const RNV_NODE_MODULES_DIR = path.join(RNV_HOME_DIR, 'node_modules');

to

export const RNV_NODE_MODULES_DIR = path.join(RNV_HOME_DIR, '../../node_modules');

it works. But i guess this may break global rnv use.

EyMaddis commented 3 years ago

The proper way would be to use something like require.resolve(), but I think I tried it and it does not result in the same file that rnv uses right now.

EyMaddis commented 3 years ago

@pavjacko I think this works: const WEBPACK = require.resolve('webpack-cli/bin/cli.js');

However, maybe this is only for me...? I wonder why you use webpack and not webpack-cli...? I am guessing the same can be done with webpack-dev-server

VladLegkowski commented 3 years ago

@EyMaddis @pavjacko

The same happens with NPM, I ran rnv build -p tizen and it throws this:

npx cross-env PLATFORM=tizen NODE_ENV=production  node /home/vl/Documents/study/test/node_modules/rnv/node_modules/webpack/bin/webpack.js -p --config ./platformBuilds/helloworld_tizen/webpack.config.prod.js 

FAILED with ERROR: 

Error: Cannot find module '/home/vl/Documents/study/test/node_modules/rnv/node_modules/webpack/bin/webpack.js'
 at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
 at Function.Module._load (internal/modules/cjs/loader.js:562:25)
 at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
 at startup (internal/bootstrap/node.js:283:19)
 at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)

Command failed with exit code 1 (EPERM): npx cross-env PLATFORM=tizen NODE_ENV=production node /home/vl/Documents/study/test/node_modules/rnv/node_modules/webpack/bin/webpack.js -p --config ./platformBuilds/helloworld_tizen/webpack.config.prod.js

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

Error: Cannot find module '/home/vl/Documents/study/test/node_modules/rnv/node_modules/webpack/bin/webpack.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)

Error: Command failed with exit code 1 (EPERM): npx cross-env PLATFORM=tizen NODE_ENV=production node /home/vl/Documents/study/test/node_modules/rnv/node_modules/webpack/bin/webpack.js -p --config ./platformBuilds/helloworld_tizen/webpack.config.prod.js
    at makeError (/home/vl/Documents/study/test/node_modules/rnv/node_modules/execa/lib/error.js:58:11)
    at handlePromise (/home/vl/Documents/study/test/node_modules/rnv/node_modules/execa/index.js:112:26)
    at process._tickCallback (internal/process/next_tick.js:68:7)

This is freshly fetched unchanged project. Running on:

Distributor ID: Ubuntu
Description:    Ubuntu 20.04.2 LTS
Release:    20.04
Codename:   focal

Node: 10.19.0 NPM: 6.14.4

I have tried suggestions from above and nothing works, how does one simply builds a project for Tizen, thanks

EyMaddis commented 3 years ago

@VladLegkowski make sure you edited the correct file, there are 2 spots where the webpack path is defined. Once for dev and once for production builds. Search for bin/webpack.js and change it to something that definitely breaks like /TEST/ to see if it lands in the output, if not: keep searching or you are not in the correct rnv folder.

VladLegkowski commented 3 years ago

@EyMaddis, can you tell me what do you refer to exactly - I see there are few different propositions to fix the issue in this thread.

VladLegkowski commented 3 years ago

Sorry, again, but is there a working branch or can someone who manages to make it work create a step by step? I know ifs a big ask but this would help I am sure to the project.

EyMaddis commented 3 years ago

@VladLegkowski this works for me: https://github.com/simpleTechs/renative/tree/simpleTechs That is the change: https://github.com/simpleTechs/renative/commit/8a9446d15f8585d4e251fcfc22177ff4fcf089eb#diff-2fe34df7a4d5ff39cd67b3c6b5c06a43c88aa0dafb62c1803f99d1612c68ac7cL56

VladLegkowski commented 3 years ago

@EyMaddis, sorry for the late reply, this worked. Thank you.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

pauliusguzas commented 1 year ago

@EyMaddis thanks for reporting this issue, is this still reproduced on latest rnv version?

mihaiblaga89 commented 1 year ago

@EyMaddis closing this, feel free to reopen if needed