import * as L from 'leaflet' gets "Can't resolve 'leaflet'" with 1.8.0-beta0
See original GitHub issueSteps to reproduce
I have an βevergreenβ Angular app (https://github.com/EOCOnline/rangertrak)
It compiled fine (& runs with known issues), in VSCode, using βng s -oβ with (with leaflet 1.7.1)
Then I run npm install leaflet@1.8.0-beta.0
and now running ng s -o
gets:
./src/app/entry/mini-lmap.component.ts:3:0-29 - Error: Module not found: Error: Can't resolve 'leaflet' in 'D:\Projects\RangerTrak\rangertrak\src\app\entry'
(which is yelling me about import * as L from 'leaflet'
)
./src/app/lmap/lmap.component.ts:2:0-31 - Error: Module not found: Error: Can't resolve 'leaflet' in 'D:\Projects\RangerTrak\rangertrak\src\app\lmap'
./node_modules/leaflet/dist/leaflet-src.js - Error: Module build failed (from ./node_modules/source-map-loader/dist/cjs.js):
Error: ENOENT: no such file or directory, open 'D:\Projects\RangerTrak\rangertrak\node_modules\leaflet\dist\leaflet-src.js'
Restarting VSCode, I get it to compile without any obvious errors, but on running I get:
Iβm no expert on this and this could well be user error or due to other packages installed (FEEL FREE TO CLOSE THIS ISSUE if so!), but I thought you might want the feedback. I do not need any of the new features, so am happy retreating to 1.7.1 for now.
Iβm super impressed at your great work, and dismayed at the war. Our hearts are with you.
Expected behavior
Current behavior
Environment
- Leaflet version:
- Browser (with version):
- OS/Platform (with version):
PS:
D:\Projects\RangerTrak\rangertrak> npm list
rangertrak@0.11.38 D:\Projects\RangerTrak\rangertrak
βββ __ngcc_entry_points__.json@ extraneous
βββ @angular-devkit/build-angular@13.2.6
βββ @angular-material-components/color-picker@7.0.1
βββ @angular-material-components/datetime-picker@7.0.1
βββ @angular/animations@13.2.6
βββ @angular/cdk@13.2.6
βββ @angular/cli@13.2.6
βββ @angular/common@13.2.6
βββ @angular/compiler-cli@13.2.6
βββ @angular/compiler@13.2.6
βββ @angular/core@13.2.6
βββ @angular/fire@7.2.1
βββ @angular/flex-layout@13.0.0-beta.38
βββ @angular/forms@13.2.6
βββ @angular/google-maps@13.2.6
βββ @angular/material@13.2.6
βββ @angular/platform-browser-dynamic@13.2.6
βββ @angular/platform-browser@13.2.6
βββ @angular/router@13.2.6
βββ @angular/service-worker@13.2.6
βββ @fortawesome/fontawesome-svg-core@1.3.0
βββ @fortawesome/free-brands-svg-icons@6.0.0
βββ @fortawesome/free-regular-svg-icons@6.0.0
βββ @fortawesome/free-solid-svg-icons@6.0.0
βββ @googlemaps/markerclusterer@1.0.26
βββ @material/banner@13.0.0
βββ @material/slider@13.0.0
βββ @material/switch@13.0.0
βββ @mdi/js@6.5.95
βββ @ngx-pwa/local-storage@13.0.2
βββ @popperjs/core@2.11.2
βββ @types/google-maps@3.2.3
βββ @types/google.maps@3.48.2
βββ @types/jasmine@3.10.3
βββ @types/leaflet.markercluster@1.4.6
βββ @types/leaflet@1.7.9
βββ @types/node@17.0.21
βββ @types/supercluster@7.1.0
βββ @what3words/api@4.0.5
βββ ag-grid-angular@27.0.0
βββ ag-grid-community@27.0.1
βββ chalk@4.1.2
βββ cross-conf-env@1.2.1
βββ dayjs@1.10.8
βββ dev-norms@1.7.1
βββ firebase@9.6.8
βββ http-server@14.1.0
βββ idb@7.0.0
βββ import-sort-cli@6.0.0
βββ import-sort-parser-typescript@6.0.0
βββ import-sort-style-module@6.0.0
βββ import-sort@6.0.0
βββ init-dev-env@1.0.0
βββ jasmine-core@4.0.1
βββ js-beautify@1.14.0
βββ jshint@2.13.4
βββ karma-chrome-launcher@3.1.1
βββ karma-coverage@2.2.0
βββ karma-jasmine-html-reporter@1.7.0
βββ karma-jasmine@4.0.1
βββ karma@6.3.17
βββ leaflet.markercluster@1.5.3
βββ leaflet.offline@2.1.0
βββ leaflet@1.8.0-beta.0
βββ npm-run-all@4.1.5
βββ prettier@2.5.1
βββ rimraf@3.0.2
βββ rxfire@6.0.3
βββ rxjs@7.5.5
βββ tslib@2.3.1
βββ tslint-config-prettier@1.18.0
βββ tslint-etc@1.13.10
βββ tslint-plugin-prettier@2.3.0
βββ tslint@6.1.3
βββ tsviz-cli@2.0.3
βββ typescript@4.5.5
βββ xlsx-style@0.8.13
βββ xlsx@0.18.3
βββ zone.js@0.11.5
on a desktop with Windows 10 & latest Chrome browser
Issue Analytics
- State:
- Created 2 years ago
- Comments:13 (3 by maintainers)
Top GitHub Comments
Its much easier to just clone the project, run
npm install
, then donpm run build
, then runnpm link
from the root of the project directory, then go into your project and tonpm link leaflet
.I did this, and was able to resolve the issue originally in this issue, and resolve the issue I was originally experiencing that was making me want to update.
So to confirm with @Falke-Design and @jonkoops, this did indeed resolve the issue with βCanβt resolve βleafletββ for me.
@BButner @VashJuan You can access the main build over https://leafletjs-cdn.s3.amazonaws.com/content/leaflet/main/leaflet-src.js You can download it and use it directly instead of useing the the npm package