Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libs.js:4 Uncaught TypeError: Cannot set property window of #<Window> which has only a getter #21

Closed
DarceyLloyd opened this issue Oct 25, 2020 · 2 comments

Comments

@DarceyLloyd
Copy link

DarceyLloyd commented Oct 25, 2020

Using some libs after gulp-terser is run js errors are caused:

libs.js:4 Uncaught TypeError: Cannot set property window of # which has only a getter.
image

So I created a test folder and setup the following:

  1. CMD: npm init -y
  2. CMD: npm i -S gsap gulp gulp-contact gulp-terser gulp-rename
  3. Create gulpfile.js
const gulp = require("gulp");
const concat = require('gulp-concat');
const terser = require('gulp-terser');

let jsFiles = [
   "./node_modules/gsap/dist/gsap.js",
];
 
let buildLibsProd = function (done) {
    gulp.src(jsFiles)
        .pipe(concat('libs.min.js'))
        .pipe(terser())
        .on("error", function (e) {
            console.log(e.toString());
            this.emit("end");
        })
        .pipe(gulp.dest('./'));
    done();
};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
gulp.task("build", gulp.parallel(
    buildLibsProd
));
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1. Run gulp build
  2. Create index.html
  3. Add script tag link in head to libs.min.js (will give you console log error).
  4. Comment out script tag from point 6 and add another script tag link in head to ./node_modules/gsap/dist/gsap.min.js (no console errors)

Any ideas?

@duan602728596
Copy link
Owner

duan602728596 commented Oct 26, 2020

I can successfully compile and get the gsap object. What is the problem with you?
1

@DarceyLloyd
Copy link
Author

I just started to create a public git repo, built from scratch and found it worked... Done a little visual compare on files and found auto complete inserted

type="module"

Into the script tag...

Well ****... Can't believe I missed that... It's always the smallest of things that get you...

@duan602728596 Thanks for taking a look though :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants