joaogarin / angular-electron

Angular2 and Electron starter using webpack
150 stars 53 forks source link

Packaging error (_resolveFilename) #77

Closed Leonardonline closed 7 years ago

Leonardonline commented 7 years ago

Running npm run electron works well but packaging and launching gave this error: I get this error on window and mac (not tried Linux).

A JavaScript error occurred in the main process Uncaught Exception: Error: Cannot find module 'C:\Users\Leonardo\Desktop\ang2ele\angular-electron\release\darwin-all\app-win...\main.js' at Module._resolveFilename (modulejs:470:15) at Function.Module._resolveFilename (C:\Users\Leonardo\Desktop\ang2ele\angular-electron\release\darwin-all\app-win32-x6...:12) at Function.Module._load (modulejs:418:25) at Object. (C:\Users\Leonardo\Desktop\ang2ele\angular-electron\ release\ darwin-all\ app-win32-x64...:8) at Object. (C:\Users\Leonardo\Desktop\ang2ele\angular-electron\ release\ darwin-all\ app-win32-x64...:3) at Module._compile (modulejs:571:32) at Object.Modul._ectensions.js (modulejs:580:10) at Module.load (modulejs:482432) at tryModuleLoad (modulejs:447:12) at Function.Module._load (modulejs:439:3)

briosheje commented 7 years ago

It looks like the issue is in the release.

Please remember that when you build your project (when you package it) all the packages that you have in your package.json in "dependencies" will be served, while those that you have manually installed using npm install won't be resolved (even those that are in devDependencies).

Can you please post your package.json and the packages you are using? the issue is likely there.

Leonardonline commented 7 years ago

It's the same as in this repo, I didn't install any package. I just removed the component about this bug

In any case here the package.json file ``` json { "name": "angular2-electron", "version": "0.0.0", "description": "Angular 2 with Electron and Webpack", "main": "main.js", "scripts": { "watch": "npm run watch:dev", "watch:dev": "webpack --watch --progress --profile", "build": "npm run build:dev", "build:dev": "webpack --progress --profile", "package": "node package.js", "package-all": "npm run package -- --all", "electron": "electron .", "webpack-test": "webpack --config webpack.test.js --progress --profile", "test": "karma start" }, "repository": { "type": "git", "url": "https://github.com/joaogarin/angular2-electron.git" }, "author": "joaogarin ", "license": "MIT", "bugs": { "url": "https://github.com/joaogarin/angular2-electron/issues" }, "homepage": "", "dependencies": { "@angular/animations": "^4.1.0", "@angular/common": "^4.1.0", "@angular/compiler": "^4.1.0", "@angular/core": "^4.1.0", "@angular/forms": "^4.1.0", "@angular/http": "^4.1.0", "@angular/material": "^2.0.0-beta.4", "@angular/platform-browser": "^4.1.0", "@angular/platform-browser-dynamic": "^4.1.0", "@angular/platform-server": "^4.1.0", "@angular/router": "^4.1.0", "@ngrx/core": "^1.2.0", "@ngrx/store": "^2.2.1", "copy-webpack-plugin": "^4.0.1", "core-js": "^2.4.1", "electron": "^1.4.3", "hammerjs": "^2.0.8", "rxjs": "^5.2.0", "webpack-target-electron-renderer": "^0.4.0", "zone.js": "^0.8.5" }, "devDependencies": { "@types/hammerjs": "^2.0.33", "@types/jasmine": "^2.2.34", "@types/moment-timezone": "^0.2.32", "@types/node": "^7.0.1", "@types/source-map": "^0.5.0", "@types/uglify-js": "^2.0.27", "@types/webpack": "^2.0.0", "angular2-template-loader": "^0.6.0", "awesome-typescript-loader": "^3.0.0-beta.18", "codelyzer": "^3.0.0", "css-loader": "^0.28.0", "electron-packager": "^8.1.0", "es6-promise-loader": "^1.0.1", "extract-text-webpack-plugin": "^2.0.0", "file-loader": "^0.11.0", "imports-loader": "^0.7.0", "istanbul-instrumenter-loader": "^2.0.0", "jasmine-core": "^2.4.1", "json-loader": "^0.5.4", "karma": "^1.3.0", "karma-chrome-launcher": "^2.0.0", "karma-coverage": "^1.0.0", "karma-jasmine": "^1.0.2", "karma-mocha-reporter": "^2.0.0", "karma-phantomjs-launcher": "^1.0.0", "karma-remap-coverage": "^0.1.4", "karma-sourcemap-loader": "^0.3.7", "karma-webpack": "2.0.2", "node-sass": "^4.0.0", "phantomjs-polyfill": "0.0.2", "phantomjs-prebuilt": "^2.1.7", "raw-loader": "0.5.1", "reflect-metadata": "0.1.10", "remap-istanbul": "^0.9.0", "rimraf": "^2.5.2", "sass-loader": "^6.0.1", "source-map-loader": "^0.2.1", "style-loader": "^0.17.0", "svg-url-loader": "^2.0.0", "ts-helpers": "^1.1.1", "tsconfig-lint": "^0.12.0", "tslint": "^5.0.0", "tslint-loader": "^3.2.0", "typescript": "~2.2.0", "url-loader": "^0.5.7", "webpack": "2.3.3", "webpack-dev-middleware": "^1.10.0", "webpack-dev-server": "2.4.3" }, "engines": { "node": ">= 4.2.1 <= 6", "npm": ">= 3" } } ```
briosheje commented 7 years ago

Did you just remove the md-slide-toggle and ran package? I did the same and it's working perfectly in my case (MacOSx sierra) (and in windows aswell).

Mind if I ask you to tell whether you have added / you are using some other modules other than the ones in the examples?

joaogarin commented 7 years ago

Hello all,

Sorry was off a long time on vacations but will take a look into this issue. thanks for all the feedback here, will try to get a solution today

joaogarin commented 7 years ago

Hello,

So, Sorry this was my bad. But was actually a simple one. The problem is I was importing the

MdSlideToggle (directive)

as if it was a module, but what should be imported is :

MdSlideToggleModule

The fix is here : https://github.com/joaogarin/angular-electron/commit/58c90ab9a4b3df44423ea9fed96e977b722a0dfc

Thanks for the feedback I will close it now;)

Leonardonline commented 7 years ago

I'm so sorry, but I had the same error.

image

I get this error running the EXE file of the app. Instead running npm run electron command everythings work fine, also the md-slider.