I create and config the webpack.config.js
module.exports = {
entry: './src/app/index.js',
output: {
path: __dirname + '/src/public',
filename: 'bundle.js'
}
};
And in my package.json
"scripts": {
"webpack": "webpack --mode development"
}
But in console show me this error:
ERROR in ./node_modules/destroy/index.js
Module not found: Error: Can't resolve 'fs' in 'C:\Users\marle\Desktop\mern-stack\node_modules\destroy'
# ./node_modules/destroy/index.js 14:17-30
# ./node_modules/send/index.js
# ./node_modules/express/lib/response.js
# ./node_modules/express/lib/express.js
# ./node_modules/express/index.js
# ./src/index.js
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! mern-stack#1.0.0 webpack: `webpack --mode development`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the mern-stack#1.0.0 webpack script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\marle\AppData\Roaming\npm-cache\_logs\2019-10-29T23_50_32_004Z-debug.log
My webpack version is 4.41.2 and webpack-cli 3.3.9
Have you tried setting the target: node in the webpack config.
https://webpack.js.org/concepts/targets/
Related
C:\wamp64\www\want>npm run dev
> # dev C:\wamp64\www\want
> npm run development
> # development C:\wamp64\www\want
> cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js
The system cannot find the path specified.
events.js:167
throw er; // Unhandled 'error' event
^
Error: spawn node_modules\webpack\bin\webpack.js ENOENT
at notFoundError (C:\Users\coolm\AppData\Roaming\npm\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:6:26)
at verifyENOENT (C:\Users\coolm\AppData\Roaming\npm\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:40:16)
at ChildProcess.cp.emit (C:\Users\coolm\AppData\Roaming\npm\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:27:25)
at Process.ChildProcess._handle.onexit (internal/child_process.js:240:12)
Emitted 'error' event at:
at ChildProcess.cp.emit (C:\Users\coolm\AppData\Roaming\npm\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:30:37)
at Process.ChildProcess._handle.onexit (internal/child_process.js:240:12)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! # development: `cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the # development script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\coolm\AppData\Roaming\npm-cache\_logs\2018-09-18T16_07_49_646Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! # dev: `npm run development`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the # dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\coolm\AppData\Roaming\npm-cache\_logs\2018-09-18T16_07_49_686Z-debug.log
C:\wamp64\www\want>
I'm trying to hook up my Laravel application with React. I followed the step of running the command "php artisan preset react" but after I was instructed to run npm install & run dev. I keep getting the following error. Does anyone have a similar problem?
Try doing full reset:
rm -rf node_modules
rm package-lock.json yarn.lock
npm cache clear --force
npm install
reactjs-basic#1.0.0 start D:\ReactJsBasic\reactjs-basic
npm run build
reactjs-basic#1.0.0 build D:\ReactJsBasic\reactjs-basic
webpack -d && cp src/index.html dist/index.html && webpack-dev-server --content-base src/ --inline --hot
Hash: c1a8c55592e0e9d3bcc0
Version: webpack 3.1.0
Time: 593ms
Asset Size Chunks Chunk Names
bundle.js 3.11 kB 0 [emitted] main
[0] ./src/app/index.js 40 bytes {0} [built]
'cp' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! reactjs-basic#1.0.0 build: webpack -d && cp src/index.html dist/index.html && webpack-dev-server --content-base src/ --inline --hot
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the reactjs-basic#1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\tufan\AppData\Roaming\npm-cache_logs\2017-07-11T07_17_38_725Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! reactjs-basic#1.0.0 start: npm run build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the reactjs-basic#1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\tufan\AppData\Roaming\npm-cache_logs\2017-07-11T07_17_38_756Z-debug.log
Reg the error:
'cp' is not recognized as an internal or external command
If you are running windows then replace cp with copy.
So I downloaded the angular2-seed project from GITHUB and am trying to get it running. I'm using the latest versions of NPM and NODE.
This is the error I'm seeing when running. I've changed the port on webpack and also have changed the port on the server as well as running sudo/non-sudo with the same results.
```
xxx:angular2-seed xxx$ sudo npm start
angular2-seed#1.0.0 start /Users/XX/Desktop/ANGULAR_TESTING/angular2-seed
npm run server
angular2-seed#1.0.0 server /Users/XX/Desktop/ANGULAR_TESTING/angular2-seed
webpack-dev-server --inline --colors --progress --display-error-details --display-cached --port 8080 --content-base src
57% 8/10 build modulesError: listen EADDRNOTAVAIL 122.122.122.122:8080
at Object.exports._errnoException (util.js:1026:11)
at exports._exceptionWithHostPort (util.js:1049:20)
at Server._listen2 (net.js:1244:19)
at listen (net.js:1293:10)
at net.js:1403:9
at GetAddrInfoReqWrap.asyncCallback [as callback] (dns.js:62:16)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:81:10)
npm ERR! Darwin 15.5.0
npm ERR! argv "/usr/local/Cellar/node/6.8.0/bin/node" "/usr/local/bin/npm" "run" "server"
npm ERR! node v6.8.0
npm ERR! npm v3.10.9
npm ERR! code ELIFECYCLE
npm ERR! angular2-seed#1.0.0 server: webpack-dev-server --inline --colors --progress --display-error-details --display-cached --port 8080 --content-base src
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the angular2-seed#1.0.0 server script 'webpack-dev-server --inline --colors --progress --display-error-details --display-cached --port 8080 --content-base src'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the angular2-seed package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! webpack-dev-server --inline --colors --progress --display-error-details --display-cached --port 8080 --content-base src
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs angular2-seed
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls angular2-seed
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/XX/Desktop/ANGULAR_TESTING/angular2-seed/npm-debug.log
npm ERR! Darwin 15.5.0
npm ERR! argv "/usr/local/Cellar/node/6.8.0/bin/node" "/usr/local/bin/npm" "start"
npm ERR! node v6.8.0
npm ERR! npm v3.10.9
npm ERR! code ELIFECYCLE
npm ERR! angular2-seed#1.0.0 start: npm run server
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the angular2-seed#1.0.0 start script 'npm run server'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the angular2-seed package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! npm run server
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs angular2-seed
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls angular2-seed
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/XX/Desktop/ANGULAR_TESTING/angular2-seed/npm-debug.log
```
The port 8080 is already in use.
Change the port at:
https://github.com/angular/angular2-seed/blob/master/package.json
on scripts.server
I'm trying to create the min.js file for my angular2 project using Tree shaking. So, earlier I were not using ag-grid for this so there was no error that time but now when I run npm run rollup its throwing this error at console. I'm not sure whether it is my fault or library fault.
When I opened the main.js file of ag-grid it is exporting the AgGridModule and Now, I'm stuck.
Below is the error message:
Module /home/knoldus/yourManager/node_modules/ag-grid-ng2/main.js does not export AgGridModule (imported by /home/knoldus/yourManager/dist/temp/client/app/assets/asset.module.js)
Error: Module /home/knoldus/yourManager/node_modules/ag-grid-ng2/main.js does not export AgGridModule (imported by /home/knoldus/yourManager/dist/temp/client/app/assets/asset.module.js)
at Module.trace (/home/knoldus/yourManager/node_modules/rollup/src/Module.js:683:30)
at /home/knoldus/yourManager/node_modules/rollup/src/Module.js:265:30
at Array.forEach (native)
at /home/knoldus/yourManager/node_modules/rollup/src/Module.js:263:25
at Array.forEach (native)
at Module.bindReferences (/home/knoldus/yourManager/node_modules/rollup/src/Module.js:256:19)
at /home/knoldus/yourManager/node_modules/rollup/src/Bundle.js:104:44
at Array.forEach (native)
at /home/knoldus/yourManager/node_modules/rollup/src/Bundle.js:104:18
Type rollup --help for help, or visit https://github.com/rollup/rollup/wiki
npm ERR! Linux 4.4.0-36-generic
npm ERR! argv "/usr/local/bin/node" "/home/knoldus/npm/bin/npm" "run" "rollup"
npm ERR! node v6.2.2
npm ERR! npm v3.10.5
npm ERR! code ELIFECYCLE
npm ERR! yourmanager#1.0.0 rollup: `rollup -f iife -c -o dist/prod/client/app/bundle.es2015.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the yourmanager#1.0.0 rollup script 'rollup -f iife -c -o dist/prod/client/app/bundle.es2015.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the yourmanager package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! rollup -f iife -c -o dist/prod/client/app/bundle.es2015.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs yourmanager
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls yourmanager
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /home/knoldus/yourManager/npm-debug.log
export default {
entry: 'src/main.aot.js',
dest: 'aot/dist/build.js', // output a single application bundle
sourceMap: false,
sourceMapFile: 'aot/dist/build.js.map',
format: 'iife',
plugins: [
nodeResolve({jsnext: true, module: true}),
commonjs({
include: ['node_modules/rxjs/**','node_modules/ng2-dragula/**',
'node_modules/ng2-uploader/**','node_modules/dragula/**',
'node_modules/ag-grid-ng2/**']`//look this`
}),
uglify()
]
}
I'm trying to write code with reacts (JSX) and transformes it with webpack (using babel). I've changed part of my "package.json" file to this:
"scripts": {
"production": "webpack -p"
}
and I'm running npm run production on command line and this is what i get:
> react-fundamentals#1.0.0 production D:\Nave\MyProjects\ReactJs\React-Fundamentals
> webpack -p
webpack 1.13.0
Usage: https://webpack.github.io/docs/cli.html
Options:
--help, -h, -?
--config
--context
--entry
--module-bind
--module-bind-post
--module-bind-pre
--output-path
--output-file
--output-chunk-file
--output-named-chunk-file
--output-source-map-file
--output-public-path
--output-jsonp-function
--output-pathinfo
--output-library
--output-library-target
--records-input-path
--records-output-path
--records-path
--define
--target
--cache [default: true]
--watch, -w
--watch which closes when stdin ends
--watch-aggregate-timeout
--watch-poll
--hot
--debug
--devtool
--progress
--resolve-alias
--resolve-loader-alias
--optimize-max-chunks
--optimize-min-chunk-size
--optimize-minimize
--optimize-occurence-order
--optimize-dedupe
--prefetch
--provide
--labeled-modules
--plugin
--bail
--profile
-d shortcut for --debug --devtool sourcemap --output-pathinfo
-p shortcut for --optimize-minimize
--json, -j
--colors, -c
--sort-modules-by
--sort-chunks-by
--sort-assets-by
--hide-modules
--display-exclude
--display-modules
--display-chunks
--display-error-details
--display-origins
--display-cached
--display-cached-assets
--display-reasons, --verbose, -v
Output filename not configured.
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "production"
npm ERR! node v0.12.3
npm ERR! npm v2.9.1
npm ERR! code ELIFECYCLE
npm ERR! react-fundamentals#1.0.0 production: `webpack -p`
npm ERR! Exit status 4294967295
npm ERR!
npm ERR! Failed at the react-fundamentals#1.0.0 production script 'webpack -p'.
npm ERR! This is most likely a problem with the react-fundamentals package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! webpack -p
npm ERR! You can get their info via:
npm ERR! npm owner ls react-fundamentals
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! D:\Nave\MyProjects\ReactJs\React-Fundamentals\npm-debug.log
Does anybody know why?
this is my "web.config.js" file:
var HtmlWebpackPlugin = require('html-webpack-plugin')
var HTMLWebpackPluginConfig = new HtmlWebpackPlugin({
template: __dirname + '/app/index.html',
filename: 'index.html',
inject: 'body'
});
module.exports = {
entry: [
'./app/index.js'
],
output: {
path: __dirname + '/dist',
filename: "index_bundle.js"
},
module: {
loaders: [
{test: /\.js$/, exclude: /node_modules/, loader: "babel-loader"}
]
},
plugins: [HTMLWebpackPluginConfig]
};
Webpack looks for a filename webpack.config.js by default. You can rename yours to that or change the script to
webpack -p web.config.js