I am new on es6. I followed a blog Beginner’s Guide To Setup ES6 Development Environment. I completed all of the process step-by-step. Then the step comes up to install the webpack development server. Then I write this code to cmd - npm run build. I get this error:
λ npm run build
-> jj#1.0.0 build C:\Users\galib\Desktop\jj
-> webpack-dev-server
The CLI moved into a separate package: webpack-cli
Please install 'webpack-cli' in addition to webpack itself to use the CLI
-> When using npm: npm i -D webpack-cli
-> When using yarn: yarn add -D webpack-cli
internal/modules/cjs/loader.js:888
throw err;
^
Error: Cannot find module 'webpack-cli/bin/config-yargs'
Require stack:
- C:\Users\galib\AppData\Roaming\npm\node_modules\webpack-dev-server\bin\webpack-dev-server.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:885:15)
at Function.Module._load (internal/modules/cjs/loader.js:730:27)
at Module.require (internal/modules/cjs/loader.js:957:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (C:\Users\galib\AppData\Roaming\npm\node_modules\webpack-dev-server\bin\web
at Module._compile (internal/modules/cjs/loader.js:1068:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
at Module.load (internal/modules/cjs/loader.js:933:32)
at Function.Module._load (internal/modules/cjs/loader.js:774:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\Users\\galib\\AppData\\Roaming\\npm\\node_modules\\webpack-dev-server\\bin\\webpack-dev-serv
]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! jj#1.0.0 build: `webpack-dev-server`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the jj#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\galib\AppData\Roaming\npm-cache\_logs\2021-06-08T18_22_59_337Z-debug.log
The article you read was probably written before Webpack's cli was moved to webpack-cli, so you might need one small extra step.
Please install 'webpack-cli' in addition to webpack itself to use the CLI
-> When using npm: npm i -D webpack-cli
-> When using yarn: yarn add -D webpack-cli
Run npm i -D webpack-cli and then you can use the Webpack CLI.
Related
I encountered this error when I run npm start to view my react app.
> react-scripts start
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module 'side-channel'
Require stack:
- C:\Users\USER-PC\Documents\Projects\frontend\Info_site\node_modules\qs\lib\stringify.js
- C:\Users\USER-PC\Documents\Projects\frontend\Info_site\node_modules\qs\lib\index.js
- C:\Users\USER-PC\Documents\Projects\frontend\Info_site\node_modules\webpack-dev-server\node_modules\express\lib\middleware\query.js
- C:\Users\USER-PC\Documents\Projects\frontend\Info_site\node_modules\webpack-dev-server\node_modules\express\lib\application.js
- C:\Users\USER-PC\Documents\Projects\frontend\Info_site\node_modules\webpack-dev-server\node_modules\express\lib\express.js
- C:\Users\USER-PC\Documents\Projects\frontend\Info_site\node_modules\webpack-dev-server\node_modules\express\index.js
- C:\Users\USER-PC\Documents\Projects\frontend\Info_site\node_modules\webpack-dev-server\lib\Server.js
- C:\Users\USER-PC\Documents\Projects\frontend\Info_site\node_modules\react-scripts\scripts\start.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (C:\Users\USER-PC\Documents\Projects\frontend\Info_site\node_modules\qs\lib\stringify.js:3:22)
at Module._compile (node:internal/modules/cjs/loader:1103:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\Users\\USER-PC\\Documents\\Projects\\frontend\\Info_site\\node_modules\\qs\\lib\\stringify.js',
'C:\\Users\\USER-PC\\Documents\\Projects\\frontend\\Info_site\\node_modules\\qs\\lib\\index.js',
'C:\\Users\\USER-PC\\Documents\\Projects\\frontend\\Info_site\\node_modules\\webpack-dev-server\\node_modules\\express\\lib\\middleware\\query.js',
'C:\\Users\\USER-PC\\Documents\\Projects\\frontend\\Info_site\\node_modules\\webpack-dev-server\\node_modules\\express\\lib\\application.js',
ules\\express\\lib\\application.js',
'C:\\Users\\USER-PC\\Documents\\Projects\\frontend\\Info_site\\node_modules\\webpack-dev-server\\node_modules\\express\\lib\\express.js',
'C:\\Users\\USER-PC\\Documents\\Projects\\frontend\\Info_site\\node_modules\\webpack-dev-server\\node_modules\\express\\lib\\express.js',
'C:\\Users\\USER-PC\\Documents\\Projects\\frontend\\Info_site\\node_modules\\webpack-dev-server\\node_modules\\express\\index.js',
'C:\\Users\\USER-PC\\Documents\\Projects\\frontend\\Info_site\\node_modules\\webpack-dev-server\\lib\\Server.js',
'C:\\Users\\USER-PC\\Documents\\Projects\\frontend\\Info_site\\node_modules\\react-scripts\\scripts\\start.js'
]
}
And then I tried to install the module with this command:
npm i side-channel
I still got an error:
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\USER-PC\AppData\Local\npm-cache\_logs\2022-10-04T15_30_26_716Z-debug-0.log
What could possibly be the problem? I ran the start command just after installing the dependencies with 'npm install' command.
It worked now. I had to delete the yarn.lock in my project, after deleting the node_modules file, then I ran the command again: npm install
You can try removing node_modules and reinstalling all modules with npm install
To show your modules as of npm 7 for windows:
Global modules: npm ls --link --global
Local modules: npm ls --link
To unistall package run
npm uninstall <module_name>
To install just run
npm install <module_name>
The best solution i have found for this problem is to uninstall and reinstall react.
This will uninstall React
to make sure it's there and show dependencies run
npm ls -g --depth=0
output:
F:\Dev\NodeJS\node22
+-- create-react-app#5.0.1
+-- express#4.14.0
to uninstall run
npm unistall -g create-react-app
to install run
npm install -g create-react-app
I'm trying to set up a project using webpack. When I try to serve it using webpack I get this:
root#d690f9010746:~/chat-webapp# npm run serve
> chat-webapp#1.0.0 serve /root/chat-webapp
> webpack serve --config webpack.config.js
internal/modules/cjs/loader.js:638
throw err;
^
Error: Cannot find module '../../lib/webpack-cli'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (/root/chat-webapp/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
at Object.<anonymous> (/root/chat-webapp/node_modules/#webpack-cli/serve/index.js:4:20)
at Module._compile (/root/chat-webapp/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! chat-webapp#1.0.0 serve: `webpack serve --config webpack.config.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the chat-webapp#1.0.0 serve 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! /root/.npm/_logs/2020-05-31T19_42_42_752Z-debug.log
The line /root/chat-webapp/node_modules/#webpack-cli/serve/index.js:4 (mentioned in the stacktrace) says: const WebpackCLI = require("../../lib/webpack-cli");. But I don't have the file /root/chat-webapp/node_modules/lib/webpack-cli - and even if I did, it's not in the #webpack-cli/serve repo, and the repo shouldn't be making assumptions about the locations of files it doesn't control.
And yet I can't find anyone or stackoverflow or anywhere else who's getting an error on the same relative path. So what am I missing? I've installed all the npm repos locally, which is a bit non-standard - could it be something to do with that?
I'm getting 'Error: Cannot find module '../scripts/start' from projects set up using create-react-app that previously worked fine, now when i run 'npm start' i'm getting this error - the only workaround seems to be rm -rf node_modules followed by npm install, but next day I run into the same problem. Any ideas how to fix this please (see full error message below) - thanks.
>react-scripts start
module.js:549
throw err;
^
Error: Cannot find module '../scripts/start'
at Function.Module._resolveFilename (module.js:547:15)
at Function.resolve (internal/module.js:18:19)
at Object.<anonymous> (/Users/DANTHORY/Dropbox/card-slider-challenge_TESTING/node_modules/.bin/react-scripts:28:25)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Function.Module.runMain (module.js:693:10)
at startup (bootstrap_node.js:191:16)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! card-slider-challenge#0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the card-slider-challenge#0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
package.json:
{
"name":"card-slider-challenge",
"version":"0.1.0",
"private":true,
"scripts":{
"start":"react-scripts start",
"build":"react-scripts build",
"test":"jest",
"eject":"react-scripts eject",
"start-api":"json-server --port 3001 --watch --static none data/db.json"
},
"dependencies":{
"react":"^16.3.2",
"react-dom":"^16.3.2",
"react-slick":"^0.23.2"
},
"devDependencies":{
"jest":"^24.0.0",
"json-server":"^0.12.2",
"react-scripts":"^1.1.4"
}
}
I had the exact same issue and I did the following:
Delete node_modules folder
Run npm install
It fixed my issue, but what it caused, I don't know.
I changed my computer and I clone my projet from Github
Delete node_modules folder
Run npm install
I've just imported my Reactjs project to a new machine on Ubuntu and installed most dependencies with npm install successfully bar the following:
npm WARN optional Skipping failed optional dependency /react-scripts/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents#1.0.17
npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents#1.1.2
Trying to run the project with npm start fails with:
> booking-frontend#0.1.0 start /root/17-visit-booker-frontend
> react-scripts start
/root/17-visit-booker-frontend/node_modules/react-scripts/scripts/start.js:33
const {
^
SyntaxError: Unexpected token {
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:374:25)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Function.Module.runMain (module.js:442:10)
at startup (node.js:136:18)
at node.js:966:3
npm ERR! Linux 4.4.0-81-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "start"
npm ERR! node v4.2.6
npm ERR! npm v3.5.2
npm ERR! code ELIFECYCLE
npm ERR! booking-frontend#0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the booking-frontend#0.1.0 start script 'react-scripts start'.
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 booking-frontend package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! react-scripts start
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs booking-frontend
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls booking-frontend
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /root/17-visit-booker-frontend/npm-debug.log
Attempting to run any npm script including npm run build all fails with the exact same error referencing the same lines in each file in the SyntaxError:
SyntaxError: Unexpected token {
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:374:25)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Function.Module.runMain (module.js:442:10)
at startup (node.js:136:18)
at node.js:966:3
Running the same scripts on my original machine, a Mac, succeed.
I've tried re-installing node/npm which do not fix the issue. Is the supposedly optional dependency causing this to fail?
Any help is appreciated.
You're using node.js v4 which does not by default support destructuring syntax (the const {field1, field2, ....} = object) that it is failing on.
You have two options:
Install a newer version of Node.js
Run node with the harmony flags that will enable this feature in version 4.x.
I am trying to 'eb deploy' a node.js with javascript sdk addition.
It works fine locally but every time I have tried to - eb deploy- it I get this in the logs
npm ERR! npm bugs node-express
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!
npm ERR! npm owner ls node-express
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /var/app/current/npm-debug.log
> node-express#0.0.0 start /var/app/current
> node main.js
{ [Error: ENOENT: no such file or directory, open '.env'] errno: -2, code: 'ENOENT', syscall: 'open', path: '.env' }
module.js:327
throw err;
^
Error: Cannot find module 'parse/node'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/var/app/current/api/common/parse.js:3:13)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
...npm ERR! code ELIFECYCLE
npm ERR! node-express#0.0.0 start: `node main.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-express#0.0.0 start script 'node main.js'.
npm ERR! This is most likely a problem with the node-express package,
I have repeatedly tried
npm install express --save
and yes I have also run npm install parse (it all works fine locally).
To no avail. Why would it all work like a charm locally but not on AWS EB ?
-Thanks for any clues.
Not sure if this will help someone. Ultimately I solved this by
'npm install moduleName --save' on all of my modules. One by one.
Still not sure why the site worked locally ?
-best of luck.