-
Notifications
You must be signed in to change notification settings - Fork 294
Sharing node_modules folder with multiple projects #681
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Yes, it possible>
|
So how should I structure the scripts element in the package.json of my projects?
I tried executing
|
I think you should create a project structure like this:
then you install your npm package by run |
Thank you for the response.
After these steps I still get the error. Thanks. |
I think you misunderstood me.
then it should work. |
Oh sorry about that.
|
For me, I put the file
|
chungngoops How do you execute |
You could also use symlinks, using |
as far as I know - npm link is only for 1 package, but I talk about folder with ~1000 modules... |
say you have this:
The best thing to do is use NODE_PATH env variable to include the node_modules directory in the projects folder. It's simple: cd "$HOME/projects/project_a"
NODE_PATH="$HOME/projects/node_modules" node app.js cd "$HOME/projects/project_b"
NODE_PATH="$HOME/projects/node_modules" node app.js cd "$HOME/projects/project_c"
NODE_PATH="$HOME/projects/node_modules" node app.js try that. NODE_PATH is an env variable that's empty by default. If NODE_PATH is not empty, it's safer to do:
|
that being said, babel dependencies should be shared by default. see # 15 here: Given the directory structure I mentioned above, Babel will reach up the directory tree and will be able to see: $HOME/projects/node_modules |
ORESoftware thank you for the assistance but may be it is not working under windows? My structure is:
I've tried following:
|
The syntax for setting env variables on windows is different try
something like that |
I recommend downloading git-bash for Windows then you will have a bash command line on Windows then you can use the original command NODE_PATH=x node foo.js |
I already use git bash, not CMD. |
humma |
maybe try windows shell then |
Tried with SET in windows CMD but got the same error( |
Hmm i will take a look at it tomorrow |
the1mills |
@Opty1712 what exactly are you trying to do? |
I want to have node-modules in the parent dir of of my identical projects |
@Opty1712 I created an example project for you clone this: https://github.com/ORESoftware/node_path_example_project follow the instructions in the readme file, let me know if it works for you |
thank you, your project works in git bash under windows! |
yeah I created those files on a mac |
I just added a video on creating multiple projects under one workspace, mostly works for learning. |
I was searching for a solution and found this: https://docs.npmjs.com/cli/v7/using-npm/workspaces - which may not have been available in 2018. Maybe it'll be good news for anyone here who hasn't figured this out. |
Hello.
As the title says I was wondering if it were possible to use the same modules folder for multiple projects so that I don't have to continuously install them using the command prompt.
Is it possible? If so how do I proceed?
Thanks.
Elia
The text was updated successfully, but these errors were encountered: