[英]ERROR MODULE NOT FOUND whenever I try to run 'npm run dev' using Next.js
Whenever I run npm run dev
I get this error.每当我运行
npm run dev
时,我都会收到此错误。
I've tried to delete node_modules
and reinstall it using npm install
but that didn't work.我尝试删除
node_modules
并使用npm install
重新安装它,但这没有用。 Then I tried to delete both node_modules
and package-lock.json
and reinstall them, that didn't work.然后我尝试删除
node_modules
和package-lock.json
并重新安装它们,但没有成功。 I even tried upgrading Node to the latest version, but I'm still getting this issue.我什至尝试将 Node 升级到最新版本,但我仍然遇到这个问题。
I appreciate any help I get.我很感激我得到的任何帮助。 Thank you in advance.
先感谢您。
Error: Cannot find module 'C:\Users\jaydev\Desktop\ecommerce\fashionsite\node_modules\postcss\lib\parser'
at createEsmNotFoundErr (node:internal/modules/cjs/loader:952:15)
at finalizeEsmResolution (node:internal/modules/cjs/loader:945:15)
at resolveExports (node:internal/modules/cjs/loader:473:14)
at Function.Module._findPath (node:internal/modules/cjs/loader:513:31)
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:911:27)
at Function.Module._load (node:internal/modules/cjs/loader:769:27)
at Module.require (node:internal/modules/cjs/loader:997:19)
at require (node:internal/modules/cjs/helpers:92:18)
at Object.552 (C:\Users\jaydev\Desktop\ecommerce\fashionsite\node_modules\next\dist\compiled\postcss-scss\scss-syntax.js:1:11590)
at __webpack_require__ (C:\Users\jaydev\Desktop\ecommerce\fashionsite\node_modules\next\dist\compiled\postcss-scss\scss-syntax.js:1:11735)
at Object.560 (C:\Users\jaydev\Desktop\ecommerce\fashionsite\node_modules\next\dist\compiled\postcss-scss\scss-syntax.js:1:400)
at __webpack_require__ (C:\Users\jaydev\Desktop\ecommerce\fashionsite\node_modules\next\dist\compiled\postcss-scss\scss-syntax.js:1:11735)
at Object.290 (C:\Users\jaydev\Desktop\ecommerce\fashionsite\node_modules\next\dist\compiled\postcss-scss\scss-syntax.js:1:260)
at __webpack_require__ (C:\Users\jaydev\Desktop\ecommerce\fashionsite\node_modules\next\dist\compiled\postcss-scss\scss-syntax.js:1:11735)
at Object.632 (C:\Users\jaydev\Desktop\ecommerce\fashionsite\node_modules\next\dist\compiled\postcss-scss\scss-syntax.js:1:3733)
at __webpack_require__ (C:\Users\jaydev\Desktop\ecommerce\fashionsite\node_modules\next\dist\compiled\postcss-scss\scss-syntax.js:1:11735) {
code: 'MODULE_NOT_FOUND',
path: 'C:\\Users\\jaydev\\Desktop\\ecommerce\\fashionsite\\node_modules\\postcss\\package.json'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! fashionsite@0.1.0 dev: `next dev`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the fashionsite@0.1.0 dev 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\jaydev\AppData\Roaming\npm-cache\_logs\2020-12-25T07_06_40_981Z-debug.log
package.json: { "name": "fashionsite", "version": "0.1.0", "private": true, "scripts": { "dev": "next dev", "build": "next build", "start": "next start" }, "dependencies": { "next": "10.0.4", "react": "17.0.1", "react-dom": "17.0.1" } } package.json: { "name": "fashionsite", "version": "0.1.0", "private": true, "scripts": { "dev": "next dev", "build": "next build ”,“开始”:“下一个开始”},“依赖项”:{“下一个”:“10.0.4”,“反应”:“17.0.1”,“react-dom”:“17.0.1”}}
.next
folder in your project's root folder..next
文件夹。node_modules
folder and package-lock.json
file too.node_modules
文件夹和package-lock.json
文件。npm cache clean --force
npm cache clean --force
npm install
npm install
npm run dev
npm run dev
If the above didn't work then open your file explorer and see if the specified file exists on the specified path or not: C:\Users\jaydev\Desktop\ecommerce\fashionsite\node_modules\postcss\lib\parser.js
如果上述方法不起作用,请打开文件资源管理器并查看指定文件是否存在于指定路径中:
C:\Users\jaydev\Desktop\ecommerce\fashionsite\node_modules\postcss\lib\parser.js
if it exists try moving your project's folder to a path other than desktop
due to windows permission problems and let me know if the problem is resolved.如果存在 windows 权限问题,请尝试将您的项目文件夹移动到
desktop
以外的路径,并让我知道问题是否已解决。
How to solve npm error "npm ERR! code ELIFECYCLE" if this isnt gonna help you,let me see what you export on server.js // Try this aswell: https://reactgo.com/npm-err-code-elifecycle/ 如何解决 npm 错误“npm ERR!code ELIFECYCLE”如果这对你没有帮助,让我看看你在 server.js 上导出的内容//试试这个: https://reactgo.com/npm-err-code-elifecycle /
I had a similar issue and found that when I was running npm install
after removing node_modules
it wasn't correctly installing all the dependencies because my node version had switched back to an older version.我遇到了类似的问题,发现当我在删除
node_modules
后运行npm install
时,它没有正确安装所有依赖项,因为我的节点版本已切换回旧版本。
Make sure your environment is configured correctly first.首先确保您的环境配置正确。 For me:
nvm use 16.0.0
and then npm install
对我来说:
nvm use 16.0.0
然后npm install
Also, when you run npm install
are there any messages that come up in the command line saying saying a dependency isn't met or something like that, might give you some hints of where to look.此外,当您运行
npm install
时,是否有任何消息出现在命令行中,说不满足依赖关系或类似的东西,可能会给您一些寻找位置的提示。
move next.config.js file from you project folder then execute npm run dev.从项目文件夹中移动 next.config.js 文件,然后执行 npm 运行开发。
or或者
comment the contents of next.config.js.注释 next.config.js 的内容。
any of the above methods will help run npm run dev.以上任何一种方法都将有助于运行 npm run dev。
make sure u already update/upgrade确保你已经更新/升级
sudo apt update
sudo apt upgrade
after u run this command在你运行这个命令之后
curl -fsSL https://deb.nodesource.com/setup_17.x | sudo -E bash
sudo apt-get install -y nodejs
sudo apt install npm
use latest node js repo avoid using sudo apt install nodejs..outdated..使用最新的 node js repo 避免使用 sudo apt install nodejs..outdated..
To get rid of this error what you have to do... just update your node.js version Hopefully, it will help you.要摆脱这个错误你必须做什么......只需更新你的 node.js 版本希望它会帮助你。
In my case it turned out to be a problem with windows permissions.在我的情况下,它原来是 windows 权限的问题。 My project was on Desktop and changing its location to a directory with more permissions helped.
我的项目在桌面上,将其位置更改为具有更多权限的目录会有所帮助。
Make sure you are in the right directory when using npm run dev.使用 npm 运行开发时,请确保您在正确的目录中。 You can also try switching to yarn.
您也可以尝试切换到纱线。
I found this article helpful ->我发现这篇文章很有帮助->
https://hidayatabisena.medium.com/how-to-solve-npm-err-code-elifcycle-when-running-npm-run-dev-on-your-next-js-project-4794226d040f https://hidayatabisena.medium.com/how-to-solve-npm-err-code-elifcycle-when-running-npm-run-dev-on-your-next-js-project-4794226d040f
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.