Hi Everyone I have a question related to the pipeline.workspace variable.
In the example below i have set pipeline.workspace as the working directory and as paths for a cli command.
Npm install creates folders under /home/vsts/work/node_modules/
while the next command when i use pipeline.workspace it points to ./home/vsts/work/1/
Am I doing something wrong? or is something up?
- task: Bash#3
displayName: 'Publish Sentry'
inputs:
targetType: 'inline'
script: |
npm install #sentry/cli
.$(Pipeline.Workspace)/node_modules/.bin/sentry-cli releases --org --project new "$(Build.BuildNumber)" --finalize
workingDirectory: "$(Pipeline.Workspace)"
The node_modules folder is pre-generate that may contains some global packages. It is not generated by the npm install command in the script. This situation exists on Microsoft-hosted Ubuntu agents and Microsoft-hosted macOS agents.
When executing the npm install command to install packages locally, there are few points you need to pay attention to :
If no node_modules folder is existing in current working directory, and also no node_modules folder is existing in any parent directory of current working directory, the npm install command will generate the node_modules folder in current working directory and install the packages into this node_modules folder.
If no node_modules folder is existing in current working directory, but the node_modules folder is existing in parent directory, the npm install command will install the packages into the existing node_modules folder in the closest parent directory.
For example, there are the following paths:
/root/dir1/node_modules
/root/dir1/dir2/node_modules
/root/dir1/dir2/dir3
When executing the npm install command in the directory "/root/dir1/dir2/dir3", the packages will be installed into "/root/dir1/dir2/node_modules".
If the node_modules folder is existing in current working directory, regardless of whether the node_modules folder is existing in parent directory or not, the npm install command will install the packages into node_modules folder in current working directory.
For example, there are the following paths:
/root/dir1/node_modules
/root/dir1/dir2/node_modules
/root/dir1/dir2/dir3/node_modules
When executing the npm install command in the directory "/root/dir1/dir2/dir3", the packages will be installed into "/root/dir1/dir2/dir3/node_modules".
Related
I have a yarn workspaces project which looks something like this:
node_modules
packages
shared
test.js
package.json
client
test.js
package.json
server
test.js
package.json
package.json
server.Dockerfile
As you can see, I have a server.Dockerfile, which builds an image of the server that I can push up to different hosting providers such as Heroku or AWS.
I copy packages and package.json into this container:
COPY packages packages
COPY package.json .
And I then install only the dependencies for the server package:
RUN cd packages/server && yarn install
All the dependencies are now in the node_modules folder, and the next thing I think of doing is to delete the packages folder to remove any unnecessary code from the docker image (e.g. the client code):
RUN rm -rf packages
The problem with this is that all the yarn workspace packages inside the node_modules folder are simply symlinks to the packages folder... so I cannot delete that folder.
How do I get yarn install to make a copy of the yarn workspace packages instead of creating symlinks?
Or, is there another way to remove all of the unused code (e.g. the client code) so that my docker image isn't bloated?
You can use yarn-workspace-isolator to extract the package with its local dependencies to avoid publishing them to npm if you don't want to.
isolate-workspace -w my-package -o ~/dist/my-package
Now, as the doc saying:
You can simply run yarn install inside of ~/dist/my-package and yarn will
install all dependencies as if you had not used workspaces at all
without having to publish any workspace dependency.
Running yarn install in workspaces does the same thing inside any package or the root directory. It installs the modules for every package and symlinks them etc.
If you want to build a docker image for just the server you should only copy that package into the container and install that as an independent package.
If the server has a dependency on the shared lib, you could publish it to npm so it can fetch it too.
I cloned project from https://github.com/victorfleite/blog-php-oop archived .
But how to create vendor folder and install any dependency?
Just use command composer install in command line (from same directory where composer.json is located). If you don't have an installed composer yet, first install it.
https://getcomposer.org/download/
Go to your Project root directory where composer.json is located
with opening a command prompt and using this commands :
make sure Your lock file contain a compatible set of packages with
running composer update command
after that you can make sure all the packages are installed with composer install command
you can find more packages with composer fund command
Go to cmd or terminal
Make sure you are in the right path (project folder directory)
use cd project_name to go inside the folder and cd .. to go back up out of the folder
In the terminal use the command composer install (if you need to install composer itself, see their official website)
Your vendor folder is installed
In the terminal type php artisan migrate and run the project
I want to install npm dependencies from a package.json in the current directory, but I want to install them to a different directory.
Can I make this setting (install directory of node_modules) project specific, so as to not interfere with my other projects?
You can try --prefix.
npm install --prefix new/path/node_modules
https://docs.npmjs.com/misc/config#prefix
NOTE: Important, that there is a node_modules folder
I got Laravel Homestead up and running, except when I issue this ssh command:
gulp
I get this error:
Local gulp not found in ~/projects/laravel
Try running: npm install gulp
That's when I noticed there was no node_modules folder at all in this directory. Weird. Is this an issue where the paths were too long for Windows when I did a vagrant up? Since the host machine for this VM is Windows and I'm sharing folders with my VM (actually I'm not, but rather I'm using phpStorm's sync so that pages will load faster on the VM), when I do a npm install am I still going to encounter the problem? Hmm...I guess Taylor Otwell is using a Mac for development. Anybody have a solution to this?
You should first install node in your local machine.
Then, navigate to your project folder and delete node_modules directory.
Run on your local machine inside project directory:
npm install gulp --save-dev
Solved it!
Yes it appears to be that some of these paths from these package installs are too long for Windows. This means you can only install the gulp package after your VM is up. Here's what I did: (I also include a step for use with phpStorm already (since it will keep server pages loading faster on the VM)
SSH into the VM and create a folder called node_modules in your project's directory (the directory where package.json is).
In phpStorm, go to File > Settings > Build, Execution, Deployment > Deployment and click on the Excluded Paths tab. Click the Add deployment path button and add the folder node_modules from step 1.
SSH back into the VM and in your projects folder (should be directory folder with package.json) and run this command: npm install. This will install all packages listed in your package.json file locally to the directory you are in, and will put the necessary files into the folder node_modules.
Now run the gulp command: gulp
UPDATE:
If you really prefer file-sharing through a mounted folder, then I've created a Gist that will guide someone through all the challenges I faced and had to resolve, including how to successfully run npm install in the guest environment:
Laravel Homestead for Windows (includes fixes)
Has anyone installed Polymer on windows? I am new to using GIT and it says you need Bower and Node and some other things to get it to work.
We are working on a simple ZIP file for people to download and get started, but we haven't finished that yet.
Until we get that ZIP done, you will want to get started by installing Bower. Bower helps you manage component installations. You can worry about GIT later.
Install Bower:
Install nodejs
execute this command:
npm install -g bower
Make a project, acquire some Polymer elements:
make a project folder
inside project folder, execute this command:
bower install Polymer/polymer-ui-elements
That will produce a number of components in your project folder to help you get started. Please refer to http://polymer-project.org for more information.
Step 1:- install node.js
Step 2:- install Git
set the Git location Path (system's environmental variable)
like:-- D:\Program Files\Git\cmd
Step 3:- install bower using npm install -g bower command check the location of npm global binaries by using command (npm config get prefix).
copy the Path and set the bower location Path (system's environmental variable)
like--> C:\Users\USER_PROFILE\AppData\Roaming\npm
the whole Path will look like..(node to Polymer)
D:\Program Files\nodejs\;D:\Program Files\Git\cmd;C:\Users\USER_PROFILE\AppData\Roaming\npm
Step 4:- using command prompt go to project folder or create a project then type
bower install polymer
inside project
folder.