[英]Error: Cannot find module 'flux'
I have a JS project that requires other JS files from its parent directory. 我有一个JS项目,该项目需要其父目录中的其他JS文件。
Here is the structure of my project: 这是我的项目的结构:
- Web 网页
- package.json package.json
- ... ...
- Core 核心
- JS JS
- ... ...
Here is the content of package.json 这是package.json的内容
{
"name": "PropertyFinder",
"version": "0.0.1",
"main": "js/app.js",
"dependencies": {
"flux": "^2.0.1",
"keymirror": "~0.1.0",
"object-assign": "^1.0.0",
"react": "^0.12.0"
},
"devDependencies": {
"browserify": "^6.2.0",
"envify": "^3.0.0",
"reactify": "^0.15.2",
"uglify-js": "~2.4.15",
"watchify": "^2.1.1"
},
"scripts": {
"start": "watchify -o js/bundle.js -v -d app.js",
"build": "browserify . -t [envify --NODE_ENV production] | uglifyjs -cm > js/bundle.min.js",
"test": "jest"
},
"author": "Jean Lebrument",
"browserify": {
"transform": [
"reactify",
"envify"
]
}
}
When I run npm start
I've these errors: 当我运行npm start
出现以下错误:
watchify -o js/bundle.js -v -d app.js watchify -o js / bundle.js -v -d app.js
Error: Cannot find module 'flux' from 'MyProject/Core/Common' Error: Cannot find module 'keyMirror' from '/MyProject/Core/Modules/SearchPage/Constants' 错误:无法从“ MyProject / Core / Common”中找到模块“ flux”错误:无法从“ / MyProject / Core / Modules / SearchPage / Constants”中找到模块“ keyMirror”
I checked and in the "node_modules" directory, the "flux" and "keymirror" directories are present. 我检查了一下,在“ node_modules”目录中,存在“ flux”和“ keymirror”目录。
Is this because the files from the Core directory are in the parent directory of the project? 这是因为Core目录中的文件位于项目的父目录中吗?
Thanks! 谢谢!
Finally, I figured out. 终于,我想通了。 I had to create a package.json
file in the Core directory with the two dependencies: flux
and keymirror
. 我必须在Core目录中创建一个package.json
文件,其中包含两个依赖项: flux
和keymirror
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.