This one is a bit messy.
Short description of the problem:
I have an Ionic project that uses the (node) package trakt.tv that uses got: https://github.com/sindresorhus/got Unfortunately this breaks the build webpack step because of this error:
PS C:\Users\Jan\Documents\yatsa> npm run ionic:build
> [email protected] ionic:build C:\Users\Jan\Documents\yatsa
> ionic-app-scripts build
[11:54:01] ionic-app-scripts 2.0.2
[11:54:01] build dev started ...
[11:54:01] clean started ...
[11:54:01] clean finished in 9 ms
[11:54:01] copy started ...
[11:54:01] transpile started ...
[11:54:06] transpile finished in 4.36 s
[11:54:06] preprocess started ...
[11:54:06] deeplinks started ...
[11:54:06] deeplinks finished in 121 ms
[11:54:06] preprocess finished in 123 ms
[11:54:06] webpack started ...
[11:54:06] copy finished in 4.72 s
[11:54:18] ionic-app-script task: "build"
[11:54:18] Error: ./node_modules/got/index.js Module not found: Error: Can't resolve 'electron' in
'C:\Users\Jan\Documents\yatsa\node_modules\got' resolve 'electron' in
'C:\Users\Jan\Documents\yatsa\node_modules\got' Parsed request is a module using description file:
C:\Users\Jan\Documents\yatsa\node_modules\got\package.json (relative path: .) after using description file:
C:\Users\Jan\Documents\yatsa\node_modules\got\package.json (relative path: .) resolve as module looking for
modules in C:\Users\Jan\Documents\yatsa\node_modules using description file:
C:\Users\Jan\Documents\yatsa\package.json (relative path: ./node_modules) Field 'browser' doesn't contain a
valid alias configuration after using description file: C:\Users\Jan\Documents\yatsa\package.json (relative
path: ./node_modules) using description file: C:\Users\Jan\Documents\yatsa\package.json (relative path:
./node_modules/electron) no extension Field 'browser' doesn't contain a valid alias configuration
C:\Users\Jan\Documents\yatsa\node_modules\electron doesn't exist .ts Field 'browser' doesn't contain a valid
alias configuration C:\Users\Jan\Documents\yatsa\node_modules\electron.ts doesn't exist .js Field 'browser'
doesn't contain a valid alias configuration C:\Users\Jan\Documents\yatsa\node_modules\electron.js doesn't
exist .json Field 'browser' doesn't contain a valid alias configuration
C:\Users\Jan\Documents\yatsa\node_modules\electron.json doesn't exist as directory
C:\Users\Jan\Documents\yatsa\node_modules\electron doesn't exist
[C:\Users\Jan\Documents\yatsa\node_modules\electron] [C:\Users\Jan\Documents\yatsa\node_modules\electron.ts]
[C:\Users\Jan\Documents\yatsa\node_modules\electron.js]
[C:\Users\Jan\Documents\yatsa\node_modules\electron.json]
[C:\Users\Jan\Documents\yatsa\node_modules\electron] @ ./node_modules/got/index.js 45:20-39 @
./node_modules/trakt.tv/trakt.js @ ./src/services/trakt.service.ts @ ./src/app/app.module.ts @
./src/app/main.ts
Error: ./node_modules/got/index.js
Module not found: Error: Can't resolve 'electron' in 'C:\Users\Jan\Documents\yatsa\node_modules\got'
resolve 'electron' in 'C:\Users\Jan\Documents\yatsa\node_modules\got'
Parsed request is a module
using description file: C:\Users\Jan\Documents\yatsa\node_modules\got\package.json (relative path: .)
after using description file: C:\Users\Jan\Documents\yatsa\node_modules\got\package.json (relative path: .)
resolve as module
looking for modules in C:\Users\Jan\Documents\yatsa\node_modules
using description file: C:\Users\Jan\Documents\yatsa\package.json (relative path: ./node_modules)
Field 'browser' doesn't contain a valid alias configuration
after using description file: C:\Users\Jan\Documents\yatsa\package.json (relative path: ./node_modules)
using description file: C:\Users\Jan\Documents\yatsa\package.json (relative path: ./node_modules/electron)
no extension
Field 'browser' doesn't contain a valid alias configuration
C:\Users\Jan\Documents\yatsa\node_modules\electron doesn't exist
.ts
Field 'browser' doesn't contain a valid alias configuration
C:\Users\Jan\Documents\yatsa\node_modules\electron.ts doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
C:\Users\Jan\Documents\yatsa\node_modules\electron.js doesn't exist
.json
Field 'browser' doesn't contain a valid alias configuration
C:\Users\Jan\Documents\yatsa\node_modules\electron.json doesn't exist
as directory
C:\Users\Jan\Documents\yatsa\node_modules\electron doesn't exist
[C:\Users\Jan\Documents\yatsa\node_modules\electron]
[C:\Users\Jan\Documents\yatsa\node_modules\electron.ts]
[C:\Users\Jan\Documents\yatsa\node_modules\electron.js]
[C:\Users\Jan\Documents\yatsa\node_modules\electron.json]
[C:\Users\Jan\Documents\yatsa\node_modules\electron]
@ ./node_modules/got/index.js 45:20-39
@ ./node_modules/trakt.tv/trakt.js
@ ./src/services/trakt.service.ts
@ ./src/app/app.module.ts
@ ./src/app/main.ts
at new BuildError (C:\Users\Jan\Documents\yatsa\node_modules\@ionic\app-scripts\dist\util\errors.js:16:28)
at callback (C:\Users\Jan\Documents\yatsa\node_modules\@ionic\app-scripts\dist\webpack.js:119:28)
at emitRecords.err (C:\Users\Jan\Documents\yatsa\node_modules\@ionic\app-scripts\node_modules\webpack\lib\Compiler.j
s:263:13)
at Compiler.emitRecords (C:\Users\Jan\Documents\yatsa\node_modules\@ionic\app-scripts\node_modules\webpack\lib\Compi
ler.js:369:38)
at emitAssets.err (C:\Users\Jan\Documents\yatsa\node_modules\@ionic\app-scripts\node_modules\webpack\lib\Compiler.js
:256:10)
at applyPluginsAsyncSeries1.err (C:\Users\Jan\Documents\yatsa\node_modules\@ionic\app-scripts\node_modules\webpack\l
ib\Compiler.js:362:12)
at next (C:\Users\Jan\Documents\yatsa\node_modules\tapable\lib\Tapable.js:154:11)
at Compiler.compiler.plugin (C:\Users\Jan\Documents\yatsa\node_modules\@ionic\app-scripts\node_modules\webpack\lib\p
erformance\SizeLimitsPlugin.js:99:4)
at Compiler.applyPluginsAsyncSeries1 (C:\Users\Jan\Documents\yatsa\node_modules\tapable\lib\Tapable.js:158:13)
at Compiler.afterEmit (C:\Users\Jan\Documents\yatsa\node_modules\@ionic\app-scripts\node_modules\webpack\lib\Compile
r.js:359:9)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] ionic:build: `ionic-app-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] ionic:build 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! C:\Users\Jan\AppData\Roaming\npm-cache\_logs\2017-07-14T09_54_18_766Z-debug.log
PS C:\Users\Jan\Documents\yatsa>
Here the relevant part again:
Module not found: Error: Can't resolve 'electron' in 'C:\Users\Jan\Documents\yatsa\node_modules\got'
resolve 'electron' in 'C:\Users\Jan\Documents\yatsa\node_modules\got'
Parsed request is a module
Now got doesn't have electron in package.json, that is correct. In normal execution it doesn't even use electron, and if I understood that correctly it only has some special config option that includes and uses electron (which then is to be though to be installed by the using project or globally):
https://github.com/sindresorhus/got#useelectronnet
https://github.com/sindresorhus/got/blob/c0c6bcf1acb7132356d5fdddcf757466071799f4/index.js#L44-L46
As I don't use electron and don't have useElectronNet set, this shouldn't be relevant to me.
Did I understand the error correctly?
Is this a app-scripts problem?
Is this a webpack problem?
Is this a got problem?
Is this my problem and I just have to add electron to my app as a dependency?
What behavior are you expecting?
My code and my packages and their dependencies don't use electron. The webpack build step should not break because of missing electron in package.json file.
Steps to reproduce:
Here is a minimal reproduction that shows the error:
ionic start electrontest blank
cd .\electrontest\
npm install trakt.tv
- Add
import * as Trakt from 'trakt.tv'; to home.ts
- Add
private trakt = new Trakt(); directly after export class HomePage { in home.ts
npm run ionic:build
Workaround is to install electron:
npm install electron --save-dev
Which @ionic/app-scripts version are you using?
2.0.2
ionic info
global packages:
@ionic/cli-utils : 1.5.0
Cordova CLI : 7.0.1
Ionic CLI : 3.5.0
local packages:
@ionic/app-scripts : 2.0.2
@ionic/cli-plugin-cordova : 1.4.1
@ionic/cli-plugin-ionic-angular : 1.3.2
Cordova Platforms : android 6.2.3
Ionic Framework : ionic-angular 3.5.0
System:
Node : v8.1.3
OS : Windows 10
Xcode : not installed
ios-deploy : not installed
ios-sim : not installed
npm : 5.1.0
PS: Bonus question: Why does the build only break on ionic cordova build and npm run ionic:build, but not on the build in ionic serve?
This one is a bit messy.
Short description of the problem:
I have an Ionic project that uses the (node) package
trakt.tvthat usesgot: https://github.com/sindresorhus/got Unfortunately this breaks the build webpack step because of this error:Here the relevant part again:
Now
gotdoesn't haveelectroninpackage.json, that is correct. In normal execution it doesn't even use electron, and if I understood that correctly it only has some special config option that includes and uses electron (which then is to be though to be installed by the using project or globally):https://github.com/sindresorhus/got#useelectronnet
https://github.com/sindresorhus/got/blob/c0c6bcf1acb7132356d5fdddcf757466071799f4/index.js#L44-L46
As I don't use electron and don't have
useElectronNetset, this shouldn't be relevant to me.Did I understand the error correctly?
Is this a app-scripts problem?
Is this a webpack problem?
Is this a
gotproblem?Is this my problem and I just have to add
electronto my app as a dependency?What behavior are you expecting?
My code and my packages and their dependencies don't use
electron. The webpack build step should not break because of missingelectronin package.json file.Steps to reproduce:
Here is a minimal reproduction that shows the error:
ionic start electrontest blankcd .\electrontest\npm install trakt.tvimport * as Trakt from 'trakt.tv';tohome.tsprivate trakt = new Trakt();directly afterexport class HomePage {inhome.tsnpm run ionic:buildWorkaround is to install electron:
npm install electron --save-devWhich @ionic/app-scripts version are you using?
2.0.2
ionic info
global packages:
local packages:
System:
PS: Bonus question: Why does the build only break on
ionic cordova buildandnpm run ionic:build, but not on the build inionic serve?