caiobiodere / cordova-template-framework7-vue-webpack

Framework7 - Vue - Webpack Cordova Template with Webpack Dev Server and Hot Module Replacement
Apache License 2.0
620 stars 154 forks source link

Clean build off master - Error: Cannot find module 'uglify-js' #43

Closed strixy closed 7 years ago

strixy commented 7 years ago

Your project looks like fun. I set it up using the command you have in the instructions.

cordova create <project_create_dir> [com.example.projectname] [ProjectClassName] --template cordova-template-framework7-vue-webpack

No errors. One warning that I think may be relevant is:

npm WARN uglifyjs-webpack-plugin@0.3.1 requires a peer of uglify-js@^2.8.0 but none was installed.

I then ran npm install

All good.

When I run webpack I get

Error: Cannot find module 'uglify-js'

So, I installed the Android platform cordova platform add android

All good.

Then I and ran cordova build android And I get

Error: Cannot find module 'uglify-js'

I checked node_modules\ and I found uglify-es, uglifyjs-webpack-plugin, uglify-to-browserify

Not sure about that uglify-es folder.

In the package.js file in dev it says,

        "uglify-js": "git://github.com/mishoo/UglifyJS2.git#harmony",
        "uglifyjs-webpack-plugin": "^0.3.0",

When I try to

npm install --save-dev uglify-js@github:mishoo/UglifyJS2#harmony

I now see a uglify-js folder in the node-modules folder, but I still get the same uglify-js not found error.

I'm on Linux and checked my $PATH for conflicting settings. No path specified for node_modules. That's all good, no reference at all.

I haven't installed uglify globally. That would probably solve the issue though it might make reference to the Harmony version difficult, breaking support for ES6 (I'm guessing?).

I'm new to webpack (previous gulp exp.) so maybe I'm using Webpack incorrectly or missing a step?

Running Node v 7.2.1 Cordova v 6.5.0 NPM v 3.10.10

Any advice appreciated. Thank you in advance.

strixy commented 7 years ago
npm install uglify-js@^2.8.0

Seems to help. Webpack runs without error.

centrual commented 7 years ago

I'll check soon, also i using this template in windows 10 with node.js 7.10.0 and everything working. This page can help you before my help: https://github.com/webpack-contrib/uglifyjs-webpack-plugin Uglify JS seems changed lately, it's probably about uglify-js plugin. For info: For ES6 code minification, you need to use harmony branch of uglify js.

Uglify js only works when you use --release command

Have a great day!

rafaellupo commented 7 years ago

@strixy @centrual same here. Tried to use harmony branch, and got same results. btw: MAC, node 7.8.0 NPM 4.2.0

centrual commented 7 years ago

Hello guys,

If you want to create issue on uglify-js git it displays these texts:

<!-- Note: for ES6 see: https://github.com/mishoo/UglifyJS2/tree/harmony#harmony -->
...
<!--
    Note: `uglify-js` only supports ES5. 
    Those wishing to minify ES6 should use `uglify-es`.
-->

They are changing the uglify js and these changes are not backward compatible. For ES6 uglify, you need to use uglify-es NOT uglify-js. uglify-js compiles ES5 only!

So since #harmony branch not compatible with v2.x we have 2 choices: 1) We can install 2.8 harmony version of uglify js npm i --save-dev https://github.com/mishoo/UglifyJS2.git#harmony-v2.8.22 2) We can wait for compatibility of uglifyjs-webpack-plugin for new version of uglify js. You can track the changes from: https://github.com/webpack-contrib/uglifyjs-webpack-plugin/issues/32

Note: I will update the dependency soon. You can update your dependencies yourself if you want with these commands:

npm rm uglify-js --save-dev
npm i --save-dev https://github.com/mishoo/UglifyJS2.git#harmony-v2.8.22
centrual commented 7 years ago

I published new package to npm