Comments (17)
NODE_PATH is a deprecated feature.
Making flow support all possible nodejs specific hacks based on the internal interface of module
seems really complicated.
from flow.
how is NODE_PATH deprecated?
And I'm happy to change my implementation to whatever else if I still can require without having do require('../../../../../../../some/path');
from flow.
I think this issue can be closed after module.system.node.resolve_dirname
was added in 0.18.1.
Docs are scarce but check the .flowconfig
in the test in e1e301c to see how it's used.
from flow.
as @dmnd mentioned; for these too lazy to search through commit changes in .flowconfig
, this worked for me:
[options]
module.system.node.resolve_dirname=node_modules
module.system.node.resolve_dirname=src
from flow.
I mispoke. It was require.paths
that is deprecated. NODE_PATH is a feature in node that is still supported.
However the way your using the feature is not recommended. General wisdom in the node community is that if you find yourself doing "../../../../../../../some/path" you've written a very large application and should look into breaking it out over multiple npm packages and putting more code in node_modules.
It would make sense for flow to support NODE_PATH, i.e. NODE_PATH=x flow ...
if set from the cli, feature detecting for mutation of it in actual source code is a slippery slope of working on in only some cases and not all.
from flow.
@frontsideair look that. I finded decision problem
https://flow.org/en/docs/config/options/#toc-module-system-node-resolve-dirname-string
from flow.
@kirushi I was doing something very similar, but I discovered that actually can hide errors from you. See #5647 (comment) -- I switched to
module.name_mapper='^\(.*\)' -> '<PROJECT_ROOT>/src/\1'
from flow.
Thanks @dmnd. I think you're right that .flowconfig
option will solve the problem outlined here. We have a few features here that need to be documented, and we already have tasks to add that.
from flow.
And it's not just nodejs specific. Browserify is the most common commonjs bundler and it supports the NODE_PATH
hack too.
And I just happen to use an internal interface. If I would give NODE_PATH
outside of the script, then I wouldn't have to call module internal interfaces. IMO it would seem much wiser to build on top of require
(or the modules browserify uses) than to use some own implementation that clearly isn't doing at its current state a very good job (#49 for instance).
from flow.
+1 for NODE_PATH support
from flow.
+1
from flow.
Thank you for reporting this issue and appreciate your patience. We've notified the core team for an update on this issue. We're looking for a response within the next 30 days or the issue may be closed.
from flow.
I'm using nix
package manager to generate the environment, which installs node packages to a folder and sets the NODE_PATH
env var to that folder. We don't want to create a node_modules
symlink in the working directory so we're doing all sorts of crazy hacks to make it work.
If flow can check NODE_PATH
in addition to node_modules
in the working directory or it could accept a command line flag for resolve_dirname
, it would make our workflow much better.
from flow.
I hit this problem again, and it was weird to see my comment is the last thing on the issue. I hope this can be implemented.
from flow.
@frontsideair me to
from flow.
The settings below don't return any errors on flow (albeit there being many purposely placed errors)
.env
NODE_PATH=src/
.flowconfig
[options] module.system.node.resolve_dirname=node_modules module.system.node.resolve_dirname=src
from flow.
In my case works:
module.name_mapper='^\(.*\)' -> '<PROJECT_ROOT>/src/\1'
module.file_ext=.jsx
module.file_ext=.js
from flow.
Related Issues (20)
- Internal type checking error under local type inference HOT 2
- Array.prototype.flat returns mixed on nested arrays HOT 2
- Question: Should this be parse error? HOT 3
- Parser: Missing decorators on `PropertyDefinition`
- Predicate functions causing internal typechecking errors HOT 1
- Strange "unconstrained" behavior with React components HOT 5
- Variable of type $Partial<A> does not accept value of type A HOT 1
- Include Hashbang in AST
- Bad error message with underconstrained-implicit-instantiation and function overload HOT 4
- Incorrect node location HOT 2
- Default value seems to be ignored
- Array.prototype.filter on non-refined nullable elements leads to unhelpful error message HOT 2
- Question about union/intersection types AST HOT 3
- Crash when parse hashbang with `{tokens: true}`
- Packages entry points support
- Cannot resolve module node:fs HOT 1
- Record types should refine Object.values HOT 2
- [flow-remove-types] doesn't remove some types HOT 1
- flow_parser.js file increased from 0.7M to 2.7M in v0.210 HOT 4
- `Omit` does not work well with unions HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flow.