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
Related
Problem
Everytime I execute my project in the terminal with the command npm start I got the following error message:
>ProjectName#1.0.0 start /workspaces/ProjectName
>electron .
/workspaces/ProjectName/node_modules/electron/dist/electron: error while loading shared libraries: libxshfence.so.1: cannot open shared object file: No such file or directory
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ProjectName#1.0.0 start:`electron .`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ProjectName#1.0.0 start script
npm ERR! This is probably not a problem with npm. There is likely additional logginh output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/node/.npm/_logs/2021-05-03T03_50_33_776Z-debug.log
Access -> 2021-05-03T03_50_33_776Z-debug.log
My Dockerfile
ARG VARIANT="14-buster"
FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:0-${VARIANT}
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends xorg openbox libnss3 libasound2 libatk-adaptor libgtk-3-0
My devcontainer.json
{
"name": "Node.js",
"build": {
"dockerfile": "Dockerfile",
"args": { "VARIANT": "14" }
},
"settings": {
"terminal.integrated.shell.linux": "/bin/bash"
},
"extensions": [
"dbaeumer.vscode-eslint",
],
"remoteUser": "node"
}
Note: I already tried to put remoteUser as root but I dont know how to put chrome on --no-sandbox mode using devcontainer.
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/
In package.json devDependencies I have webpack-dev-server installed:
"webpack-dev-server": "3.2.1"
but when I run the start script, which looks as follows:
"start": "webpack-dev-server --inline --config demo/webpack.config.js --port 9000 --mode development"
I get this error:
sh: 1: webpack-dev-server: not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! your-app#2.0.5 start: `webpack-dev-server --inline --config demo/webpack.config.js --port 9000 --mode development`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the your-app#2.0.5 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
What is the issue here?
Notice that every script you want access in cli, script should be install in your system as globally.
you can install globally every script you want with npm. that way add -g in your command when you want install package.
In your case, you should run this command:
npm install webpack-dev-server -g
after that you can access webpack-dev-server in your command. like your code webpack-dev-server added to start script in your package.json file.
After that, you can run npm install webpack-dev-server --save-dev command to add this package in your node_modules.
Now, you have access webpack-dev-server in your cli. As you write in your start script in your package.json.
My app by default, did a "production" install, which didn't install devDepencies.
I did:
export NODE_ENV=development
before executing npm install and it installed dev dependecies, so now it works.
I am working on a laravel project with reactjs.
When I installed react-addons-css-transition-group the following message was displayed:
+ react-addons-css-transition-group#15.6.0
added 5 packages and removed 1124 packages in 68.535s
After that laravel-mix and npm watch do not work.
The following message is displayed when npm watch is executed:
'cross-env' is not recognized as an internal or external command,
operable program or batch file.
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" "watch" "--scripts-prepend-node-path=auto"
npm ERR! node v6.11.0
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! # watch: `cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the # watch script 'cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.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 package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! D:\wamp64\www\test\npm-debug.log
I am facing this error while running react js app. I already install current version of node js and npm.
~/Desktop/music/client
$ npm start
client#1.0.0 start C:\Users\DIU\Desktop\music\client
./node_modules/webpack-dev-server/bin/webpack-dev-server.js --hot --progress --colors --inline --quiet --history-api-fallback
'.' is not recognized as an internal or external command,
operable program or batch file.
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" "start"
npm ERR! node v7.5.0
npm ERR! npm v4.1.2
npm ERR! code ELIFECYCLE
npm ERR! client#1.0.0 start: ./node_modules/webpack-dev-server/bin/webpack-dev-server.js --hot --progress --colors --inline --quiet --history-api-fallback
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the client#1.0.0 start script './node_modules/webpack-dev-server/bin/webpack-dev-server.js --hot --progress --colors --inline --quiet --history-api-fallback'.
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 client package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! ./node_modules/webpack-dev-server/bin/webpack-dev-server.js --hot --progress --colors --inline --quiet --history-api-fallback
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs client
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls client
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\DIU\Desktop\music\client\npm-debug.log
This worked for me:
ctrl + Alt + Delete,
Task Manager,
Find all running instances of node server and kill them.
install your packages.
basic idea is that your node server keeps running in the background even after you think you've closed it in the console and it is accessing all your node files.