Giter VIP home page Giter VIP logo

Comments (25)

handoing avatar handoing commented on May 2, 2024 7

I upgraded node v9.2.0 and solved it.

from parcel.

xswei avatar xswei commented on May 2, 2024 4

my node version is v6, this issue was be fixed after upgrade to v8

from parcel.

purtuga avatar purtuga commented on May 2, 2024 3

Looking forward to this fix pending (#253).

To the project maintainers:
Having recently heard about Parcel and it's zero configuration feature, I was eager to try it out on a new project, but quickly found that the "Getting Started" example just fails, which needless to say is not a good reflection upon this library. My suggestion (until this issue is fixed) would be for you to list the current limitation (requires nodeJS v > 6) on your README file and website.

Appreciate the work that has gone into this library and for the introduction of a zero config bundler. I will revisit this again in the future...

from parcel.

ljharb avatar ljharb commented on May 2, 2024 2

In strict or sloppy mode, you can always use Function(‘return this’)() in every engine except CSP-enabled browsers (however, for those, you can use window || self.

from parcel.

phobal avatar phobal commented on May 2, 2024 2

i try it, since v7.0.0 to v7.9.0, it cannot run, but when I use v8.0.0, it done !, so, I guess parcel need Node version is greater than or equal to v8.0.0

from parcel.

vishnuramana avatar vishnuramana commented on May 2, 2024 2

Still getting the same issue.

Node version : 9.5.0
Parcel version : 1.5.1

Just have a button in my html page which on clicking calls the clickHandler function in the js file. Get an error saying 'ReferenceError: clickHandler is not defined'. I could find the function in the built js file under dist.

Note: have configured to use babel. But still.. 😞

from parcel.

wqcstrong avatar wqcstrong commented on May 2, 2024 1

@phobal But what results to the problem, I would like to konw the explaniation. It's all konwn that require is supported at the node @v6.x.x

from parcel.

benbonnet avatar benbonnet commented on May 2, 2024

Was on node6, upgrading to node8 let me run this example without issues (and the most basic one advertised on the 'getting started' page)

node8 is obviously required; so is a minimal .babelrc setup

Not a dropin webpack replacement at all :/, was too good to be true. Using the same package.json, I'm now getting hellish bugs when trying replace a webpack conf within an es6 app (...spreads breaks, among other things), end up sad not being able to investigate further at the moment

from parcel.

jamiebuilds avatar jamiebuilds commented on May 2, 2024

We're relying on non-strict mode. Some tool (most likely Babel is adding in the "use strict".

We should probably update the prelude.js file to find the correct global to attach to.

@ljharb What's the best way to get global (whether it be window/self/global/this) today?

from parcel.

bigtunacan avatar bigtunacan commented on May 2, 2024

Just chiming in; I was getting a different error #31, but after that issue was fixed I'm now getting this error with node6.

from parcel.

marcioj avatar marcioj commented on May 2, 2024

I was looking into the issue but I think even fixing the use strict problem we will have problems with babel transforming require = (function (modules, cache, entry) { ... }) to require = function (modules, cache, entry) { ... }; when the project is built.
So in node 7 and further, when the script is compiled by parcel and the browser loads, we have correctly require = (function (modules, cache, entry) { ... })([modules]) which is a iife. Because it uses the files under src/* which are not compiled it uses the original file. But in node 6 and before it generates require = function (modules, cache, entry) { ... };([modules]). Which makes the page render nothing.

Not sure how to fix that. Maybe we could make babel ignore this specific file and just copy it to lib?

Also is it a bad idea to just not support node 6? I think people using parcel are mostly testing it or creating new stuff, in this case they can at least use a more up to date node version.

from parcel.

bigtunacan avatar bigtunacan commented on May 2, 2024

I just ended up upgrading to Node 8x series since it is on LTS

from parcel.

ollieSk8 avatar ollieSk8 commented on May 2, 2024

just upgrade the node version to v8.9.3,can fix this problem.

from parcel.

wqcstrong avatar wqcstrong commented on May 2, 2024

@xswei me,too! But do you know why?

from parcel.

phobal avatar phobal commented on May 2, 2024

@wqcstrong right. node 6.x was supported, however, it run in node V8 environment, in browser cannot support require

from parcel.

xswei avatar xswei commented on May 2, 2024

@wqcstrong @phobal 老铁 parcel只支持8以上版本,具体原因知道吗?

from parcel.

 avatar commented on May 2, 2024

Also bumped into this on Node 6.11. The first few lines of the generated file follow. Note the implicit global assignment in require = function(...), which is the reason the error is thrown in strict mode. Manually deleting the use strict line, or using var require = function... prevents the error from being thrown, but the generated file actually never calls the require function.

"use strict";

// modules are defined as an array
// [ module function, map of requires ]
//
// map of requires is short require name -> numeric require
//
// anything defined in a previous bundle is accessed via the
// orig method which is the require for previous bundles

require = function (_require) {

Edit: the reason require doesn't get called is an extra semicolon after the definition of function(modules, cache, entry) { ... });(...). That semicolon means the function expression isn't immediately invoked.

from parcel.

wqcstrong avatar wqcstrong commented on May 2, 2024

@xswei 上面的大佬大概说了导致报错的原因了 @guilhermeasg :1、删除严格模式;2、var声明变量

from parcel.

wqcstrong avatar wqcstrong commented on May 2, 2024

@guilhermeasg Hey buddy,I have tried to find the semicolon you said in the complied file, but I did not find it after reading what you said.

from parcel.

 avatar commented on May 2, 2024

@wqcstrong thanks for following up. I uploaded the bundled file to a gist for direct examination. This file has been generated, as in the example in the main page, simply by running parcel index.html on the provided file.

Note that line 11 is an implicit global definition, which is forbidden in strict mode (L1), hence the error. Furthermore, take a look at L80:

});({7:[function(require,module,exports) {

The expression after the semicolon is supposed to be the argument to the previously defined function (making it an IIFE), but the semicolon breaks it into an object declaration with no side effects.

from parcel.

perymimon avatar perymimon commented on May 2, 2024

what wrong to write
var require = function (_require) {
instead of just
require = function (_require) { ?

It make it global just fine

from parcel.

 avatar commented on May 2, 2024

@perymimon see my comment for the reason

from parcel.

 avatar commented on May 2, 2024

Just as an update:

I'm getting this issue with parcel bundler version 1.4.1 & node version v9.4.0.

Both fresh installs today.

from parcel.

davidnagli avatar davidnagli commented on May 2, 2024

@mike-rotate Can you try it again using the new Parcel version?

from parcel.

devongovett avatar devongovett commented on May 2, 2024

Node 6 support was just merged in #789. Should be released in 1.6.0 this week!

from parcel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.