npm module doesn't require folder_name
See original GitHub issueDescription
I install and require elasticsearch
in my code, but the compiled js errored with
Uncaught Error: Cannot find module 'elasticsearch/src/lib/loggers' from 'elasticsearch/src/lib/log.js'
Expected behavior
It should require node_modules/elasticsearch/src/lib/loggers/index.js
Actual behavior
As error message.
demo project
run npm start
and open development tool console for the error message.
If I modify the module, fix the require syntax to require("./loggers/index.js")
,
it success and error at next folder requirement.
I’ve tried to alter the brunch config’s like
javascripts: {
joinTo: {
'app.js': /^(app|node_modules)/
}
}
but still no luck.
Environment
- Brunch: 2.9.1
- Node: v7.0.0
- NPM: 4.0.1
- Operating system: macOS 10.12.1
package.json
contents
{
"name": "brunch-app",
"version": "0.1.0",
"scripts": {
"start": "brunch watch --server",
},
"dependencies": {
"elasticsearch": "^12.0.1"
},
"devDependencies": {
"auto-reload-brunch": "^2.0.0",
"brunch": "^2.0.0",
"clean-css-brunch": "^2.0.0",
"css-brunch": "^2.0.0",
"javascript-brunch": "^2.0.0",
"uglify-js-brunch": "^2.0.0"
}
}
brunch config contents
exports.files = {
javascripts: {joinTo: 'app.js'},
stylesheets: {joinTo: 'app.css'},
templates: {joinTo: 'app.js'},
plugins: {
babel: {}
},
npm: {
enabled: true
}
};
Issue Analytics
- State:
- Created 7 years ago
- Reactions:3
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Importing files in node package without including dist folder ...
So here I have to specify the dist folder name in import path. Is there way to specify just 'my-lib/foo' omitting dist folder...
Read more >folders - npm Docs
When installing locally, this means that you can require("packagename") to load its main module, or require("packagename/lib/path/to/sub/module") to load ...
Read more >Requiring modules in Node.js: Everything you need to know
Requiring a folder. Modules don't have to be files. We can also create a find-me folder under node_modules and place an ...
Read more >CommonJS modules | Node.js v19.3.0 Documentation
The semantics of the Node.js require() function were designed to be general enough to support reasonable directory structures. Package manager programs such as ......
Read more >Modules required from outside of root directory does not find ...
Yes. If you do require('foo') , then it looks node_modules/foo first in the directory of the module you're requiring from ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@rafbgarcia Ah no, I just switch to other packaging tools after that.
I just lost many hours I guess related to this. Using Brunch because it’s by default with Phoenix but I just can’t get a simple npm module that require some lodash functions to work properly (unless I import them myself in my app.js …)
And this issue is open for a year and a half ? I was excited to use Brunch because it seems simple and I hate Webpack but I guess I’ve no choice.