[英]'Module Not Found Issue'
There is an issue in my Project and stating 'Cannot find module ' after several attempts and I am trying to install and uninstall the packages simultaneously, the issue is not resolving.我的项目中存在问题,并在多次尝试后显示“无法找到模块”,我尝试同时安装和卸载软件包,但问题并未解决。
{
"name": "tooling-01-starting-project",
"version": "1.0.0",
"description": "JavaScript The Complete Guide",
"main": "eslint.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "webpack"
},
"author": "Junaid Jawed",
"license": "ISC",
"devDependencies": {
"eslint": "^7.32.0",
"webpack": "^5.53.0",
"webpack-cli": "^4.8.0",
"webpack-dev-server": "^4.2.1"
},
"dependencies": {
"grunt": "^1.4.1"
}
} }
Below this is my webpack.config.js file coding:-下面是我的 webpack.config.js 文件编码:-
/* eslint-disable no-undef */
const path = require('path');
module.exports =
{
entry:'./src/app.js',
output:
{
filename:'app.js',
path:path.resolve(__dirname,'assets','scripts')
}
};
const path2 = require('path');
module.exports =
{
entry:'./node_modules/webpack/bin/webpack.js',
output:
{
filename:'webpack.js',
path2:path2.resolve(__dirname,'webpack','bin')
}
};
Also above I have attached an screenshot of my error in npm command prompt:-同样在上面,我在 npm 命令提示符中附上了我的错误截图:-
Can somebody tell me what is the problem of this issue?有人可以告诉我这个问题的问题是什么吗? I think it doesn't found the file location where my webpack.js file is located.
我认为它没有找到我的 webpack.js 文件所在的文件位置。
I've been stuck with that kind of issues for times in the past.过去,我曾多次遇到此类问题。
One thing that it could be, is about the project location.可能的一件事是关于项目位置。 Here it is said that's in
E:\
, try to relocate it in C:\Users\YourUser\Documents\MyProject
and do the following:这里据说在
E:\
中,尝试将其重新定位在C:\Users\YourUser\Documents\MyProject
中并执行以下操作:
Run npm i
command, and start the solution.运行
npm i
命令,并启动解决方案。 If it doesn't work, could be an issue regarding the version of node that's installed in your computer...如果它不起作用,可能是关于您计算机中安装的节点版本的问题......
I have faced the same problem.我遇到了同样的问题。 To solve this just add
"type": "module"
in your package.json file and you are good to go!要解决这个问题,只需在package.json文件中添加
"type": "module"
即可!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.