caiobiodere / cordova-template-framework7-vue-webpack

Framework7 - Vue - Webpack Cordova Template with Webpack Dev Server and Hot Module Replacement
Apache License 2.0
620 stars 154 forks source link

Hello, i have a problem when run: cordova run browser -- --lr #97

Closed bodiab19 closed 6 years ago

bodiab19 commented 6 years ago

$ cordova run browser -- --lr Before deploy hook started... Checking is node modules installed... Node modules already installed. Error happened on main chain: { Error: Cannot find module 'lodash/assign' at Function.Module._resolveFilename (module.js:555:15) at Function.Module._load (module.js:482:25) at Module.require (module.js:604:17) at require (internal/module.js:11:18) at Object. (D:\work\mobile\soccer\node_modules\cheerio\lib\options.js:1:76) at Module._compile (module.js:660:30) at Object.Module._extensions..js (module.js:671:10) at Module.load (module.js:573:32) at tryModuleLoad (module.js:513:12) at Function.Module._load (module.js:505:3) code: 'MODULE_NOT_FOUND' } (node:3152) UnhandledPromiseRejectionWarning: Error: Cannot find module 'lodash/assign' at Function.Module._resolveFilename (module.js:555:15) at Function.Module._load (module.js:482:25) at Module.require (module.js:604:17) at require (internal/module.js:11:18) at Object. (D:\work\mobile\soccer\node_modules\cheerio\lib\options.js:1:76) at Module._compile (module.js:660:30) at Object.Module._extensions..js (module.js:671:10) at Module.load (module.js:573:32) at tryModuleLoad (module.js:513:12) at Function.Module._load (module.js:505:3) (node:3152) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:3152) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

u01jmg3 commented 6 years ago

Slightly off track from your issue but I too am seeing the DeprecationWarning: Unhandled promise rejections are deprecated whenever I have a JavaScript compilation error

Are we missing a catch somewhere that is now needed for newer Node? Also, when the Webpack build does fail it doesn't specify what file there is a problem in only that Webpack has failed to build. Is it possible to provide this info in the error?

ralbear commented 6 years ago

Something similar here, after run cordova run browser -- --lr i can see and use the web at http://localhost:8081 but i have that two issues at the end of the loading.

$ cordova run browser -- --lr
[...]
webpack: Compiled successfully.
Cordova hook completed. Resuming to run your cordova command...
Unable to load PlatformApi from platform. Error: Cannot find module 'C:\app_phonegap\platforms\browser\cordova\Api.js'
(node:17660) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Unhandled "error" event. (The platform "browser" does not appear to be a valid cordova platform. It is missing API.js. browser not supported.)
(node:17660) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
caiobiodere commented 6 years ago

Hey guys before running could you check your npm, node and cordova versions?

Npm version: 5.6.0 Node version: 8.9.4 Cordova version: 8.0.0 cordova-android version: 7.0.0 cordova-browser version: 5.0.3

screen shot 2018-03-06 at 12 20 27 pm
ralbear commented 6 years ago

Actually i have this versions:

Npm: 5.6.0 Node: 8.9.4 Cordova: 8.0.0 Cordova-android: 7.0.0 Cordova-browser: 4.1.0

ralbear commented 6 years ago

I try to update my cordova browser version and get the same error

C:\project\cordova platform update browser
Using cordova-fetch for cordova-browser@~5.0.1
Updating browser project...
Unable to load PlatformApi from platform. Error: Cannot find module 'C:\project\platforms\browser\cordova\Api.js'
(node:9852) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Unhandled "error" event. (The platform "browser" does not appear to be a valid cordova platform. It is missing API.js. browser not supported.)
(node:9852) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
caiobiodere commented 6 years ago

hey, @ralbear try this:

Remove the platform which you try to run on it (browser, ios, android, and etc.) cordova platform rm browser

Add the platform again cordova platform add browser

You can run cordova run browser -- --lr

ralbear commented 6 years ago

Yep, i try that but it gives some related errors, i come back with more info when i have it working!

ralbear commented 6 years ago

Finally i start from scratch, create a fresh new cordova project based in this repo.

The cordova run browser -- --lr works fine. This method still droping this error but all looks fine. (node:52024) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

To make the android emulator works, finally i must run the emulator from android studio and when i have it up. I run cordova run android and then the app gets packed, the apk generated and then launched in the emulator. This is not the perfect solution because i have not the live reload in android but is ok for my actual project.

caiobiodere commented 6 years ago

Hey @ralbear some people had the same problem. We fixed that changing our webpack.config.js

From -> {test: /\.vue$/, loader: 'vue-loader', options: {loaders: {js: {loader: 'babel-loader', options: {presets: ['env'], plugins: ['transform-object-rest-spread']}}}}}, {test: /\.js$/, exclude: /node_modules\/(?!(framework7|framework7-vue|template7|dom7)\/).*/, use: {loader: 'babel-loader', options: {presets: ['env'], plugins: [ 'transform-runtime', 'transform-object-rest-spread' ]}}}

To -> {test: /\.vue$/, exclude: /node_modules/, loader: 'vue-loader', options: {loaders: {js: {loader: 'babel-loader', options: {presets: ['env'], plugins: ['transform-object-rest-spread']}}}}}, {test: /\.js$/, exclude: /node_modules(\/|\\)(?!(framework7|framework7-vue|template7|dom7)(\/|\\)).*/, use: {loader: 'babel-loader', options: {presets: ['env'], plugins: [ 'transform-runtime', 'transform-object-rest-spread' ]}}}

ralbear commented 6 years ago

With this i must find solved the (node:52024) [DEP0018] DeprecationWarning: [...] or the android enviroment run? After updating my webpack.config.js i have the same problems.

caiobiodere commented 6 years ago

Just to make your android enviroment running because like others you are using windows, could you show me the error when you are using android?

ralbear commented 6 years ago

When i run cordova run android -- --lr i only get this extra error, at the middle of the log

[...]
Starting a Gradle Daemon (subsequent builds will be faster)
publishNonDefault is deprecated and has no effect anymore. All variants are now published.
Configuration 'compile' in project ':app' is deprecated. Use 'implementation' instead.
The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use Task.doLast(Action) instead.
        at build_esumd79ylzhrq8b8aw89zqt7i.run(M:\app_beta\platforms\android\app\build.gradle:144)
:CordovaLib:preBuild UP-TO-DATE
[...]

when the process finish the app-debug.apk package was correctly created but the android enviroment don´t start by itself.

[...]
:app:packageDebug
:app:assembleDebug
:app:cdvBuildDebug

BUILD SUCCESSFUL in 37s
47 actionable tasks: 3 executed, 44 up-to-date
Built the following apk(s):
        M:\app_beta\platforms\android\app\build\outputs\apk\debug\app-debug.apk
Copying platform cordova files...
(node:17772) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: EISDIR: illegal operation on a directory, link 'M:\app_beta\platforms\browser\www\favicon.ico' -> 'M:\app_beta\www\platform_cordova_files\browser\favicon.ico'
(node:17772) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Also i can move the app-debug.apk to the android emulator and it works fine.

caiobiodere commented 6 years ago

I got a similar error when my android paths were wrong could you check your android paths? I don't know how to use that on windows platform.

caiobiodere commented 6 years ago

another thing you could try starting from scratch using my last release: https://github.com/caiobiodere/cordova-template-framework7-vue-webpack/releases/tag/2.0.5

ralbear commented 6 years ago

The android paths are ok, i have issues with this when i install it. I´m not sure if can be a incompatibility with the new Android Studio version. I come back with my feedback when i try the new release :)

caiobiodere commented 6 years ago

hey @ralbear how was it?

MontyZhao commented 6 years ago

I have the same error with @ralbear too.

When I run cordova build android: ` Before deploy hook started... Checking is node modules installed... Node modules already installed. Error happened on main chain: { Error: Cannot find module 'lodash/assign' at Function.Module._resolveFilename (module.js:536:15) at Function.Module._load (module.js:466:25) at Module.require (module.js:579:17) at require (internal/module.js:11:18) at Object. (/Users/ouxuan/CODE/sea_code/nfcDev/node_modules/cheerio/lib/options.js:1:76) at Module._compile (module.js:635:30) at Object.Module._extensions..js (module.js:646:10) at Module.load (module.js:554:32) at tryModuleLoad (module.js:497:12) at Function.Module._load (module.js:489:3) code: 'MODULE_NOT_FOUND' } Error: Cannot find module 'lodash/assign'

`

When I run cordova platform rm android: ` Removing platform android from config.xml file... Error: npm: Command failed with exit code 1 Error output: Cannot download "https://github.com/sass/node-sass/releases/download/v4.8.3/darwin-x64-57_binding.node":

ETIMEDOUT

Timed out attemping to establish a remote connection

`

MontyZhao commented 6 years ago

And when I create a new project, and do it again, it works! This time , there is no errors anymore!

caiobiodere commented 6 years ago

I think that's closed now