I am building an e-comm-site clone with react and it was working perfectly fine until I added a 'StateProvider.js', 'reducer.js' and updated my 'index.js' to have my <App /> wrapped like so: <StateProvider initialState={initialState} reducer={reducer}> <App /> </StateProvider>. Now when I run 'npm start' it says:
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module 'ajv-formats'
Require stack:
/Users/Desktop/E-Comm-Site/e-comm-site/node_modules/webpack-dev-server/node_modules/schema-utils/dist/validate.js
/Users/Desktop/E-Comm-Site/e-comm-site/node_modules/webpack-dev-server/node_modules/schema-utils/dist/index.js
/Users/Desktop/E-Comm-Site/e-comm-site/node_modules/webpack-dev-server/lib/Server.js
/Users/Desktop/E-Comm-Site/e-comm-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. (/Users/Desktop/E-Comm-Site/e-comm-site/node_modules/webpack-dev-server/node_modules/schema-utils/dist/validate.js:25:20)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159: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: [
'/Users/Desktop/E-Comm-Site/e-comm-site/node_modules/webpack-dev-server/node_modules/schema-utils/dist/validate.js',
'/Users/Desktop/E-Comm-Site/e-comm-site/node_modules/webpack-dev-server/node_modules/schema-utils/dist/index.js',
'/Users/Desktop/E-Comm-Site/e-comm-site/node_modules/webpack-dev-server/lib/Server.js',
'/Users/Desktop/E-Comm-Site/e-comm-site/node_modules/react-scripts/scripts/start.js'
]
}.
The code is identical to that of the course I am following and it works still for them at this stage. Although he has serviceWork.js and I have reportWebVitals.js. Although I can't see how that would be the issue as it was working fine before?
I had the same issue. I removed node_modules and package-lock.json and did npm install and the error has gone
Run the npm install from the root of the project directory command in your terminal.
If the problem persists after running that and restarting your server, the dependency ajv-formats is referenced by your project but not listed as a dependency in your package.json file. Tou can do this by running the command npm install ajv-formats --save
Related
As of yesterday, I suddenly started getting this error when running the 'npm start' script in my create-react-app. I never had this issue before, and have not changed any configuration or package.json files in or out of react-scripts. terser-webpack-plugin is installed at the location and its "main" is:
"main": "dist/index.js",
I have tried reinstalling node_modules with no luck. I also tried the solution here: Use latest terser-webpack-plugin with Webpack5
throw err;
^
Error: Cannot find module 'Z:\Documents\chat-test\my-app\node_modules\terser-webpack-plugin\dist\index.js'. Please verify that the package.json has a valid "main" entry
at tryPackage (node:internal/modules/cjs/loader:353:19)
at Function.Module._findPath (node:internal/modules/cjs/loader:566:18)
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
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> (Z:\Documents\chat-test\my-app\node_modules\react-scripts\config\webpack.config.js:18:22)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32) {
code: 'MODULE_NOT_FOUND',
path: 'Z:\\Documents\\chat-test\\my-app\\node_modules\\terser-webpack-plugin\\package.json',
requestPath: 'terser-webpack-plugin'
}
Possible fixes, try either or both:
npm i --save-dev terser-webpack-plugin
Remove package.lock and run npm i
I´m getting an error using yarn to create a nextJS app, i just run:
yarn create next-app --typescript
then just run:
yarn dev
usually this error is showed:
yarn dev
yarn run v1.22.17
$ next dev
ready - started server on 0.0.0.0:3000, url: http://localhost:3000
node:internal/modules/cjs/loader:933
const err = new Error(message);
^
Error: Cannot find module 'styled-jsx'
Require stack:
- C:\Users\Felipe\Desktop\programação-estudos\alura-challenge-front-end-1\node_modules\next\dist\server\render.js
- C:\Users\Felipe\Desktop\programação-estudos\alura-challenge-front-end-1\node_modules\next\dist\server\next-server.js
- C:\Users\Felipe\Desktop\programação-estudos\alura-challenge-front-end-1\node_modules\next\dist\server\next.js
- C:\Users\Felipe\Desktop\programação-estudos\alura-challenge-front-end-1\node_modules\next\dist\server\lib\start-server.js
- C:\Users\Felipe\Desktop\programação-estudos\alura-challenge-front-end-1\node_modules\next\dist\cli\next-dev.js
- C:\Users\Felipe\Desktop\programação-estudos\alura-challenge-front-end-1\node_modules\next\dist\bin\next
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.mod._resolveFilename (C:\Users\Felipe\Desktop\programação-estudos\alura-challenge-front-end-1\node_modules\next\dist\build\webpack\require-hook.js:183:28)
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\Felipe\Desktop\programação-estudos\alura-challenge-front-end-1\node_modules\next\dist\server\render.js:11:18)
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) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\Users\\Felipe\\Desktop\\programação-estudos\\alura-challenge-front-end-1\\node_modules\\next\\dist\\server\\render.js',
'C:\\Users\\Felipe\\Desktop\\programação-estudos\\alura-challenge-front-end-1\\node_modules\\next\\dist\\server\\next-server.js',
'C:\\Users\\Felipe\\Desktop\\programação-estudos\\alura-challenge-front-end-1\\node_modules\\next\\dist\\server\\next.js',
'C:\\Users\\Felipe\\Desktop\\programação-estudos\\alura-challenge-front-end-1\\node_modules\\next\\dist\\server\\lib\\start-server.js',
'C:\\Users\\Felipe\\Desktop\\programação-estudos\\alura-challenge-front-end-1\\node_modules\\next\\dist\\cli\\next-dev.js',
'C:\\Users\\Felipe\\Desktop\\programação-estudos\\alura-challenge-front-end-1\\node_modules\\next\\dist\\bin\\next'
]
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
but even if i install the dependecies the same error apears with another dependencie, if i use npm works how it´s supose to works.
edit: my pc had a error in the ssd and some file had been corrupted, but i alredy reinstall npm and yarn but dind´t work.
I am starts working on expressJs nodeJs but stuck at a beginning point to run the node server.js command. I think any module is missing to install but i`m not recognize which one is missing.Im working on linux(ubuntu) operating system. Please help me to out this problem.
iron#iron-System-Product-Name:/media/iron/1d6c195f-2350-423c-a3f0-0500c92e580a/admin-panel/node-admin-master$ node server.js
module.js:442
throw err;
^
Error: Cannot find module '/media/iron/1d6c195f-2350-423c-a3f0-0500c92e580a/admin-panel/node-admin-master/config/env/undefined'
at Function.Module._resolveFilename (module.js:440:15)
at Function.Module._load (module.js:388:25)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/media/iron/1d6c195f-2350-423c-a3f0-0500c92e580a/admin-panel/node-admin-master/config/routes.js:6:14)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/media/iron/1d6c195f-2350-423c-a3f0-0500c92e580a/admin-panel/node-admin-master/server.js:14:13)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
Node Version: v6.2.2
Npm version: 3.9.5
it take undefined of variable which may you declare in config/env/undefined.
Please check your env file or if possible share with me .
Thanks
With the error, i suspect you are missing iron-node module.
To simply install in project, run
npm i iron-node
to install and save it in the project's package.json, run:
npm i iron-node --save
to install it in your computer, do:
npm i -g iron-node
However, since this is a development dependency, you should install it as one and save it in package.json, by:
npm i iron-node -D --save
I have installed node js on my windows 10 machine, and the version is v4.4.2 but when I try to run npm install or even check npm version it throwing the following error. Any help would be greatly appreciated
Error: Cannot find module 'readable-stream'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:286:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (C:\Users\nmadasu\AppData\Roaming\npm\node_modules\npm
\node_modules\are-we-there-yet\index.js:2:14)
at Module._compile (module.js:434:26)
at Object.Module._extensions..js (module.js:452:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
Also, after reading other solutions to this problem, npm install gulp -g, npm install 'readable-stream' or any other suggestion I read and tried did not work. It appears any command I try with npm throws the error below.
Error: Cannot find module 'readable-stream'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:286:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (C:\Users\nmadasu\AppData\Roaming\npm\node_modules\npm
\node_modules\are-we-there-yet\index.js:2:14)
at Module._compile (module.js:434:26)
at Object.Module._extensions..js (module.js:452:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
I have also tried uninstalling node and reinstalling and same issue persists.
I figured it out, when I uninstalld I did not delete all the files. There were the node/npm files in my C: directory and failed to realize there were a bunch of npm module files in my / directory. So after uninstalling and deleting all related files I reinstalled node/npm and it is now working.
After all the checks its clear you need to uninstall and re-install node:
sudo npm cache clean -f
sudo npm install -g n
sudo n stable // for stable version
sudo n 0.12.7 // for specific version like v0.12.7
// check the node version after install
node -v
If you are on windows make sure after you Uninstall node you %appdata% or C:\Users\admin\AppData\Roaming and delete all the npm folders that have been created here by your previous install.
git clone https://github.com/nodejs/readable-stream into global node_modules folder
My code was working previously before, but seems to have stopped working. I tried yo angular:route api but this error was returned:
Error: Cannot find module 'ansi-styles'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/usr/local/lib/node_modules/generator-angular/node_modules/chalk/index.js:2:12)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
I have added all the dependencies required to my package file, update npm (which is now on 2.0.0alpha), all npm packages, and ran npm install. The site still works when I grunt serve.
(The O.P.):
I found the reason I got the error. I had to change the npm root folder and reinstalled my packages in the default folder and now it works.
Just needed to run npm install here. Was a fresh clone out of Git.
Installing the module globally working for me.
npm install ansi-styles -g