Closed shaosh closed 6 years ago
@shaosh I haven't encountered this error and the error doesn't say much. I can take a look if you create a minimal github project reproducing the error.
Thanks
@anandanand84
I think I found more clue.
I did create a minimal project and reproduced the error. When I build the project with webpack, it gave these warnings:
` WARNING in ./node_modules/uglify-js/tools/node.js 24:11-32 Critical dependency: the request of a dependency is an expression @ ./node_modules/uglify-js/tools/node.js @ ./node_modules/cwise/lib/cwise-transform.js @ ./node_modules/cwise/cwise.js @ ./node_modules/keras-js/lib/activations/selu.js @ ./node_modules/keras-js/lib/activations/index.js @ ./node_modules/keras-js/lib/index.js @ ./node_modules/technicalindicators/lib/patterndetection/patterndetection.js @ ./node_modules/technicalindicators/lib/index.js @ ./src/index.js
WARNING in ./node_modules/source-map/lib/source-map/source-map-generator.js 8:45-52 Critical dependency: require function is used in a way in which dependencies cannot be statically extracted @ ./node_modules/source-map/lib/source-map/source-map-generator.js @ ./node_modules/source-map/lib/source-map.js @ ./node_modules/escodegen/escodegen.js @ ./node_modules/static-module/index.js @ ./node_modules/cwise/lib/cwise-transform.js @ ./node_modules/cwise/cwise.js @ ./node_modules/keras-js/lib/activations/selu.js @ ./node_modules/keras-js/lib/activations/index.js @ ./node_modules/keras-js/lib/index.js @ ./node_modules/technicalindicators/lib/patterndetection/patterndetection.js @ ./node_modules/technicalindicators/lib/index.js @ ./src/index.js
WARNING in ./node_modules/source-map/lib/source-map/source-map-consumer.js 8:45-52 Critical dependency: require function is used in a way in which dependencies cannot be statically extracted @ ./node_modules/source-map/lib/source-map/source-map-consumer.js @ ./node_modules/source-map/lib/source-map.js @ ./node_modules/escodegen/escodegen.js @ ./node_modules/static-module/index.js @ ./node_modules/cwise/lib/cwise-transform.js @ ./node_modules/cwise/cwise.js @ ./node_modules/keras-js/lib/activations/selu.js @ ./node_modules/keras-js/lib/activations/index.js @ ./node_modules/keras-js/lib/index.js @ ./node_modules/technicalindicators/lib/patterndetection/patterndetection.js @ ./node_modules/technicalindicators/lib/index.js @ ./src/index.js
WARNING in ./node_modules/source-map/lib/source-map/source-node.js 8:45-52 Critical dependency: require function is used in a way in which dependencies cannot be statically extracted @ ./node_modules/source-map/lib/source-map/source-node.js @ ./node_modules/source-map/lib/source-map.js @ ./node_modules/escodegen/escodegen.js @ ./node_modules/static-module/index.js @ ./node_modules/cwise/lib/cwise-transform.js @ ./node_modules/cwise/cwise.js @ ./node_modules/keras-js/lib/activations/selu.js @ ./node_modules/keras-js/lib/activations/index.js @ ./node_modules/keras-js/lib/index.js @ ./node_modules/technicalindicators/lib/patterndetection/patterndetection.js @ ./node_modules/technicalindicators/lib/index.js @ ./src/index.js `
It seems the error is caused by patterndetection.js. When I commented those lines off in the index.js, the warnings disappear and the code can run without any issues.
And here is my webpack.config.js
` var path = require('path'); var webpack = require('webpack');
module.exports = { entry: { index: './src/index.js' }, output: { path: path.join(__dirname, './dist'), filename: '[name].js' }, resolve: { extensions: ['.js', '.jsx'] }, target: 'node', module: { loaders: [ { test: /.js|jsx$/, loader: 'babel-loader', exclude: /node_modules/ } ] } } var path = require('path'); var webpack = require('webpack');
module.exports = { entry: { index: './src/index.js' }, output: { path: path.join(__dirname, './dist'), filename: '[name].js' }, resolve: { extensions: ['.js', '.jsx'] }, target: 'node', module: { loaders: [ { test: /.js|jsx$/, loader: 'babel-loader', exclude: /node_modules/ } ] } } `
@anandanand84 Could you take a look at the error and code I pasted above? It seems to be related with the patterndetection.js.
@shaosh Is there a sample project which I can look into, its hard to debug without reproducing the issue.
@anandanand84 Sorry. Here is the repo: https://github.com/shaosh/macd-demo My node version is 8.4.0.
Steps: npm i npm run build npm start
@shaosh Thankyou I'll check
The reason for this issue is webpack which is based on uglifyjs can't uglify uglifyjs. Similar issue was also referred here: https://github.com/mishoo/UglifyJS2/issues/1847 https://github.com/webpack-contrib/uglifyjs-webpack-plugin/issues/226 https://github.com/webpack/webpack/issues/4786
But I haven't seen any solutions.
After being blocked here by this issue for a month, I finally figured out a workaround after came across this issue https://github.com/webpack/webpack/issues/603
If anyone sees the same issue and your application happens to be a server-side project as I do, just don't webpack the node_modules.
var nodeExternals = require('webpack-node-externals');
...
module.exports = {
...
target: 'node', // in order to ignore built-in modules like path, fs, etc.
externals: [nodeExternals()], // in order to ignore all modules in node_modules folder
...
};
@shaosh does this mean we can close this issue?
@anandanand84 Yeah, I'll do it.
Hi @anandanand84 ,
Thank you so much for developing this amazing set of tools, which I've been looking for for a while.
When I use this package without webpack, everything is good. However when I pack my code with webpack, it starts complaining
return /*require.resolve*/(!(function webpackMissingModule() { var e = new Error("Cannot find module \".\""); e.code = 'MODULE_NOT_FOUND'; throw e; }())); ^ Error: Cannot find module "."
when I tried to run my code. (webpack build did not give any error).
It did not change anything after I added ts-loader or
mainFields: ["module", "main"]
into my webpack.config.I am quite sure this error is caused by technicalindicators, since it runs well after I remove this package.
Just wondering if you saw this kind of error before, and if you can give any help.
Thanks, shaosh