You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Field 'browser' doesn't contain a valid alias configuration #8036
The build fails when trying to perform a build involving a requirejs dependency which also requires other files.
In this case the following error appears:
Field 'browser' doesn't contain a valid alias configuration
The error does not occur if the required file dependency has no dependencies, and it appears to have been introduced after 1.2.6. This affects both jit & aot builds.
What you are describing is expected behavior. tsconfig settings affect .ts files. Webpack handles module resolution within javascript files and it cannot resolve the module in question. Which makes sense since required-module/strings isn't a package and is not in the app's root. (The two places webpack looks for module dependencies.)
If this worked previously, it could really be considered a defect.
To make it work there are several options:
change the dependency to ./strings
change the file extension of logger.js to logger.ts
move the entire directory inside the root (src in this case)
make required-module an actual package and link it
Also, as an aside, requirejs is unused and not needed.
I am getting this error in the latest CLI, with rxjs 5.4.2.....
Field 'browser' doesn't contain a valid alias configuration
C:\Users\tpadle01\IdeaProjects\onland-ui\src\rxjs\operators.js doesn't exist
as directory
C:\Users\tpadle01\IdeaProjects\onland-ui\src\rxjs\operators doesn't exist
looking for modules in C:\Users\tpadle01\IdeaProjects\onland-ui\src
using description file: C:\Users\tpadle01\IdeaProjects\onland-ui\package.json (relative path: ./src)
Field 'browser' doesn't contain a valid alias configuration
after using description file: C:\Users\tpadle01\IdeaProjects\onland-ui\package.json (relative path: ./src)
using description file: C:\Users\tpadle01\IdeaProjects\onland-ui\package.json (relative path: ./src/rxjs/operators)
no extension
Reacted by Ray Suelzer, JeanPaul Attard, Augusto Moura, Alexey Boklin, Johan CHOUQUET, Vincent, Charl, Demis Bellot, Jonas Praem, AbelardoLG and 5 more
Angular 5 requires rxjs 5.5+.
Please note that this is unrelated to the original issue. If you continue to experience the issue, please open a separate issue.
Reacted by Santosh Cheler, clcaza, Sebastian, João Eudes Lima, David Faure, Nik Karbaum, Bobby Nguyen, Andžej Maciusovič, Brian Marcalla Conza, Charl and 2 more
Using ng serve --aot I got useless Field 'browser' doesn't contain a valid alias configuration error, but switching to ng serve I got expected error saying that main tag is not closed.
Reacted by Michal Margiel, Benjamin DANIEL, Bartek, Eros Stein and [io]
Our problem was only the @ng-bootstrap/ng-bootstrap library, we have the version 1.0.0-beta.6 that broken everything and need to downgrade to the version 1.0.0-beta.5 that's works fine for us.
I got this error when I hade my page modules declared in both src/app/app.module.ts and their specific module e.g. src/pages/test/test.module.ts. Running ngc gave a much better error diagnosis:
./node_modules/.bin/ngc
Error: Type TestPage in /src/pages/test/test.ts is part of the declarations of 2 modules:
AppModule in /src/app/app.module.ts and TestPageModule in /src/pages/test/test.module.ts!
Please consider moving TestPage in /src/pages/test/test.ts to a higher module that imports
AppModule in /src/app/app.module.ts and TestPageModule in /src/pages/test/test.module.ts. You
can also create a new NgModule that exports and includes TestPage in /src/pages/test/test.ts
then import that NgModule in AppModule in /src/app/app.module.ts and TestPageModule in
/src/pages/test/test.module.ts.
I would suggest running ngc if you are getting an weird webpack build error like this as it seems like various issues are causing this specific misleading error.
Reacted by Vivo, Abner Souza, dakados, Alberto Martinez, Igo Jeferson, Raschid and Nikola Guzina
Reacted by Vivo, Fang Jin, David Helgestad, Antonio Figueroa and Raschid
I have recently upgraded my all packages along-with application on angular 7. After that few of my packages started failing complaining "Field 'browser' doesn't contain a valid alias configuration".
Module not found: Error: Can't resolve 'D:\develop\PoseidonNext\Packages\ng-datacontextselectorcomponent\src\styles.css' in 'D:\develop\PoseidonNext\Packages\ng-datacontextselectorcomponent' resolve 'D:\develop\PoseidonNext\Packages\ng-datacontextselectorcomponent\src\styles.css' in 'D:\develop\PoseidonNext\Packages\ng-datacontextselectorcomponent' using description file: D:\develop\PoseidonNext\Packages\ng-datacontextselectorcomponent\package.json (relative path: .) Field 'browser' doesn't contain a valid alias configuration using description file: D:\develop\PoseidonNext\Packages\ng-datacontextselectorcomponent\package.json (relative path: ./src/styles.css) no extension Field 'browser' doesn't contain a valid alias configuration D:\develop\PoseidonNext\Packages\ng-datacontextselectorcomponent\src\styles.css doesn't exist .ts Field 'browser' doesn't contain a valid alias configuration D:\develop\PoseidonNext\Packages\ng-datacontextselectorcomponent\src\styles.css.ts doesn't exist .tsx Field 'browser' doesn't contain a valid alias configuration D:\develop\PoseidonNext\Packages\ng-datacontextselectorcomponent\src\styles.css.tsx doesn't exist .mjs Field 'browser' doesn't contain a valid alias configuration D:\develop\PoseidonNext\Packages\ng-datacontextselectorcomponent\src\styles.css.mjs doesn't exist .js Field 'browser' doesn't contain a valid alias configuration D:\develop\PoseidonNext\Packages\ng-datacontextselectorcomponent\src\styles.css.js doesn't exist as directory D:\develop\PoseidonNext\Packages\ng-datacontextselectorcomponent\src\styles.css doesn't exist [D:\develop\PoseidonNext\Packages\ng-datacontextselectorcomponent\src\styles.css] [D:\develop\PoseidonNext\Packages\ng-datacontextselectorcomponent\src\styles.css.ts] [D:\develop\PoseidonNext\Packages\ng-datacontextselectorcomponent\src\styles.css.tsx] [D:\develop\PoseidonNext\Packages\ng-datacontextselectorcomponent\src\styles.css.mjs] [D:\develop\PoseidonNext\Packages\ng-datacontextselectorcomponent\src\styles.css.js] @ multi ./src/styles.css styles[0]
Before upgrade, everything was working fine. Below, I have pasted package.json.
@Juanperezc I don't have webpack config and now we can't eject as well. I just migrated my app on angular 7 and it suddenly started failing. I don't have any external dependency as well!
@rahulsahay19 I have about the same error as you, except with my own scss files. And also it only do it when I run my unit tests (using jasmine). My app serves fine though. Didn't try it to build with prod config yet.
So I have just found a fix for my problem, so you might want to check it too if it was similar to mine : in angular.json, I had to change the short styles path for the full one
before "styles": [ "src/styles/style.scss" ],
after "styles": [ "apps/our-project-name/src/styles/style.scss" ],
So you might want to revise your angular.json. I hope this can help.
In my case this is what did the trick, I changed this part of my code (angular.json) "test": { "builder": "@angular-devkit/build-angular:karma", "options": { "main": "src/test.ts", "polyfills": "src/polyfills.ts", "tsConfig": "tsconfig.spec.json", "karmaConfig": "karma.conf.js", "assets": ["src/favicon.ico", "src/assets"], "styles": ["src/styles.css"], "scripts": [] } },
This issue seems to contain reports of a similar error on different situation from several different versions of Angular CLI. It doesn't include a lot of reproductions however, so it's very hard for us to pinpoint and fix the problem.
If you're still experiencing this error today can you open a new issue with a reproduction please? Thank you.
Activity
clydin commentedon Oct 13, 2017
What you are describing is expected behavior.
tsconfigsettings affect.tsfiles. Webpack handles module resolution within javascript files and it cannot resolve the module in question. Which makes sense sincerequired-module/stringsisn't a package and is not in the app's root. (The two places webpack looks for module dependencies.)If this worked previously, it could really be considered a defect.
To make it work there are several options:
./stringslogger.jstologger.tssrcin this case)required-modulean actual package and link itAlso, as an aside,
requirejsis unused and not needed.mark-holmes commentedon Oct 13, 2017
Thanks clydin.
This is unfortunate if it is to be considered a defect as I am unable to act on any of your suggestions without incurring significant work.
At the end of the day I need to be able to alias a javascript path, which worked up to v1.2.6
Normally this would be solved by editing the alias field of the webpack config.
#7287 Seems to be related.
TylerDev6 commentedon Nov 1, 2017
I am getting this error in the latest CLI, with rxjs 5.4.2.....
Field 'browser' doesn't contain a valid alias configuration
C:\Users\tpadle01\IdeaProjects\onland-ui\src\rxjs\operators.js doesn't exist
as directory
C:\Users\tpadle01\IdeaProjects\onland-ui\src\rxjs\operators doesn't exist
looking for modules in C:\Users\tpadle01\IdeaProjects\onland-ui\src
using description file: C:\Users\tpadle01\IdeaProjects\onland-ui\package.json (relative path: ./src)
Field 'browser' doesn't contain a valid alias configuration
after using description file: C:\Users\tpadle01\IdeaProjects\onland-ui\package.json (relative path: ./src)
using description file: C:\Users\tpadle01\IdeaProjects\onland-ui\package.json (relative path: ./src/rxjs/operators)
no extension
jeanpaulattard commentedon Nov 6, 2017
I am getting the issue @TylerDev6 mentioned... It seems that instead of looking into the /node_modules folder, it's searching within the src folder...
This started happening after upgrading to angular v5, angular cli 1.5 and typescript 2.4.2
clydin commentedon Nov 6, 2017
Angular 5 requires rxjs 5.5+.
Please note that this is unrelated to the original issue. If you continue to experience the issue, please open a separate issue.
mrusmanali commentedon Nov 7, 2017
i started getting this error after i upgraded to angular 5 and angular cli 1.5.0
Angular CLI: 1.5.0
Node: 8.9.0
OS: darwin x64
Angular: 5.0.0
... animations, common, compiler, core, forms, http
... language-service, platform-browser, platform-browser-dynamic
... platform-server, router
@angular/cli: 1.5.0
@angular/compiler-cli: 4.4.6
@angular/tsc-wrapped: 4.4.6
@angular-devkit/build-optimizer: 0.0.32
@angular-devkit/core: 0.0.20
@angular-devkit/schematics: 0.0.35
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.8.0
@schematics/angular: 0.1.0
typescript: 2.6.1
webpack: 3.8.1
Jeff-Li-Realster commentedon Dec 8, 2017
I had the exactly same error here.
Field 'browser' doesn't contain a valid alias configuration@angular/cli: 1.6.0
@angular/compiler-cli: 5.1.0
anjmao commentedon Dec 9, 2017
Also I was getting this error when html markup is invalid. Just make your html closing tag invalid, in my case I forgot to change closing main tag.
Using
ng serve --aotI got uselessField 'browser' doesn't contain a valid alias configurationerror, but switching tong serveI got expected error saying that main tag is not closed.tecnocat commentedon Dec 11, 2017
Same error here, we rollback the npm update today to fix, working versions:
Bad versions (cause the related error browser):
Hope this help.
geenino commentedon Dec 12, 2017
Hi, tecnocat,
Thank you so much. your solution worked for me.
tecnocat commentedon Dec 12, 2017
Our problem was only the
@ng-bootstrap/ng-bootstraplibrary, we have the version 1.0.0-beta.6 that broken everything and need to downgrade to the version 1.0.0-beta.5 that's works fine for us.We fix with this commands:
And everything works great.
CoreyCole commentedon Dec 13, 2017
I got this error when I hade my page modules declared in both
src/app/app.module.tsand their specific module e.g.src/pages/test/test.module.ts. Runningngcgave a much better error diagnosis:I would suggest running
ngcif you are getting an weird webpack build error like this as it seems like various issues are causing this specific misleading error.18 remaining items
Update package.json
tskweres commentedon Mar 27, 2018
ionic app-scripts ^3.1.4 works for me.
I was using 3.1.8 and this error occurred. Roll back to 3.1.4 and try it
Do not rely on baseUrl and instead import files via relative pathing
rahulsahay19 commentedon Dec 15, 2018
Hi Guys,
I have recently upgraded my all packages along-with application on angular 7. After that few of my packages started failing complaining "Field 'browser' doesn't contain a valid alias configuration".
Module not found: Error: Can't resolve 'D:\develop\PoseidonNext\Packages\ng-datacontextselectorcomponent\src\styles.css' in 'D:\develop\PoseidonNext\Packages\ng-datacontextselectorcomponent' resolve 'D:\develop\PoseidonNext\Packages\ng-datacontextselectorcomponent\src\styles.css' in 'D:\develop\PoseidonNext\Packages\ng-datacontextselectorcomponent' using description file: D:\develop\PoseidonNext\Packages\ng-datacontextselectorcomponent\package.json (relative path: .) Field 'browser' doesn't contain a valid alias configuration using description file: D:\develop\PoseidonNext\Packages\ng-datacontextselectorcomponent\package.json (relative path: ./src/styles.css) no extension Field 'browser' doesn't contain a valid alias configuration D:\develop\PoseidonNext\Packages\ng-datacontextselectorcomponent\src\styles.css doesn't exist .ts Field 'browser' doesn't contain a valid alias configuration D:\develop\PoseidonNext\Packages\ng-datacontextselectorcomponent\src\styles.css.ts doesn't exist .tsx Field 'browser' doesn't contain a valid alias configuration D:\develop\PoseidonNext\Packages\ng-datacontextselectorcomponent\src\styles.css.tsx doesn't exist .mjs Field 'browser' doesn't contain a valid alias configuration D:\develop\PoseidonNext\Packages\ng-datacontextselectorcomponent\src\styles.css.mjs doesn't exist .js Field 'browser' doesn't contain a valid alias configuration D:\develop\PoseidonNext\Packages\ng-datacontextselectorcomponent\src\styles.css.js doesn't exist as directory D:\develop\PoseidonNext\Packages\ng-datacontextselectorcomponent\src\styles.css doesn't exist [D:\develop\PoseidonNext\Packages\ng-datacontextselectorcomponent\src\styles.css] [D:\develop\PoseidonNext\Packages\ng-datacontextselectorcomponent\src\styles.css.ts] [D:\develop\PoseidonNext\Packages\ng-datacontextselectorcomponent\src\styles.css.tsx] [D:\develop\PoseidonNext\Packages\ng-datacontextselectorcomponent\src\styles.css.mjs] [D:\develop\PoseidonNext\Packages\ng-datacontextselectorcomponent\src\styles.css.js] @ multi ./src/styles.css styles[0]Before upgrade, everything was working fine. Below, I have pasted package.json.
package.json
{ "name": "@kognifai/poseidon-ng-datacontextselectorcomponent", "version": "2.2.0-alpha.0", "description": "Angular implementation of Poseidon data context selector component", "author": "Kongsberg Digital", "license": "SEE LICENSE IN LICENSE", "main": "./dist/bundles/poseidon-ng-datacontextselectorcomponent.umd.js", "types": "./dist/kognifai-poseidon-ng-datacontextselectorcomponent.d.ts", "scripts": { "build": "ng-packagr -p package.json && mkdir dist\\assets && copy /Y .\\src\\assets\\*.* dist\\assets\\", "update": "copy /Y package.publish.json dist\\package.json", "test": "ng test --watch=false", "lint": "ng lint" }, "keywords": [ "poseidon", "data context selector component" ], "dependencies": { "@angular/animations": "^7.1.2", "@angular/common": "^7.1.2", "@angular/compiler": "^7.1.2", "@angular/core": "^7.1.2", "@angular/forms": "^7.1.2", "@angular/http": "^7.1.2", "@angular/platform-browser": "^7.1.2", "@angular/platform-browser-dynamic": "^7.1.2", "@angular/router": "^7.1.2", "@kognifai/poseidon-datacontextservice": "^2.2.0-alpha.0", "@kognifai/poseidon-dropdown-directive": "^2.2.0-alpha.0", "@kognifai/poseidon-ng-datacontextservice": "^2.2.0-alpha.0", "core-js": "^2.5.4", "rxjs": "~6.3.3", "zone.js": "^0.8.26" }, "devDependencies": { "@angular-devkit/build-angular": "^0.11.2", "@angular/cli": "^7.1.2", "@angular/compiler-cli": "^7.1.2", "@angular/language-service": "^7.1.2", "@kognifai/poseidon-script-version-bump": "^2.2.0-alpha.0", "@kognifai/poseidon-tslint": "^2.2.0-alpha.0", "@types/jasmine": "^3.3.0", "@types/jasminewd2": "^2.0.6", "@types/node": "^10.12.12", "codelyzer": "^4.5.0", "core-js": "^2.6.0", "jasmine-core": "^3.3.0", "jasmine-spec-reporter": "^4.2.1", "karma": "^3.1.3", "karma-chrome-launcher": "^2.2.0", "karma-coverage-istanbul-reporter": "^2.0.4", "karma-jasmine": "^2.0.1", "karma-jasmine-html-reporter": "^1.4.0", "ng-packagr": "^4.4.5", "protractor": "^5.4.1", "ts-node": "^7.0.1", "tsickle": "^0.34.0", "tslint": "^5.11.0", "typescript": "~3.1.6" }, "ngPackage": { "lib": { "entryFile": "public_api.ts", "externals": { "@kognifai/poseidon-datacontextservice": "DataContextService", "@kognifai/poseidon-ng-datacontextservice": "DataContextNgService", "@kognifai/poseidon-dropdown-directive": "DropdownDirective" } }, "deleteDestPath": false, "whitelistedNonPeerDependencies": [ "." ] } }tsconfig.json
tsconfig.app.json
Kindly let me know, if there is anything needs to be changed from my side.
Thanks,
Rahul
Juanperezc commentedon Jan 3, 2019
My solution was simply add alias to webpack config
rahulsahay19 commentedon Jan 4, 2019
@Juanperezc I don't have webpack config and now we can't eject as well. I just migrated my app on angular 7 and it suddenly started failing. I don't have any external dependency as well!
proAppleEater commentedon Jan 23, 2019
@rahulsahay19 I have about the same error as you, except with my own scss files. And also it only do it when I run my unit tests (using jasmine). My app serves fine though. Didn't try it to build with prod config yet.
proAppleEater commentedon Jan 23, 2019
So I have just found a fix for my problem, so you might want to check it too if it was similar to mine : in angular.json, I had to change the short styles path for the full one
before
"styles": [ "src/styles/style.scss" ],after
"styles": [ "apps/our-project-name/src/styles/style.scss" ],So you might want to revise your angular.json. I hope this can help.
mgechev commentedon Jan 23, 2019
This seems like an old issue and there are a lot of potential solutions above. Can we close as fixed in the latest CLI or I'm missing something?
bh-hsi commentedon May 16, 2019
We cannot. This is still an issue with
6.0.8:In my case, it appears to be a missing style.css file, which it's never complained about until I upgraded.
dragoljub-bogicevic-devtech commentedon Sep 23, 2019
In my case this is what did the trick, I changed this part of my code (angular.json)
"test": {"builder": "@angular-devkit/build-angular:karma","options": {"main": "src/test.ts","polyfills": "src/polyfills.ts","tsConfig": "tsconfig.spec.json","karmaConfig": "karma.conf.js","assets": ["src/favicon.ico", "src/assets"],"styles": ["src/styles.css"],"scripts": []}},to this
"test": {"builder": "@angular-devkit/build-angular:karma","options": {"main": "src/test.ts","polyfills": "src/polyfills.ts","tsConfig": "tsconfig.spec.json","karmaConfig": "karma.conf.js","assets": ["src/favicon.ico", "src/assets"],"styles": [],"scripts": []}},filipesilva commentedon Oct 1, 2019
This issue seems to contain reports of a similar error on different situation from several different versions of Angular CLI. It doesn't include a lot of reproductions however, so it's very hard for us to pinpoint and fix the problem.
If you're still experiencing this error today can you open a new issue with a reproduction please? Thank you.
angular-automatic-lock-bot commentedon Nov 1, 2019
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.