Azure DevOps npm build wrong folder - reactjs

I am building build pipeline for react.js project.
The two first steps are
npm install
and
npm run build --prod
The first one is working. However the second one is not. I choose good working folder that contains package.json - Web/{AppName}
The same Web/{AppName} is used as directory to npm install command which works fine.
The error while running build command is:
4 verbose stack Error: ENOENT: no such file or directory, open 'C:\agent\_workDC45Build\7\s\Web\package.json'
Why this step is looking for package.json in Web folder instead of Web/{AppName} which is just set in build configuration?
EDIT:

Related

getting error when run npm start command with gatsby

When I run command npm start it's giving me error
ERROR
gatsby develop
Start development server. Watches files, rebuilds, and hot reloads if
something changes
And when I run command gatsby build it's giving me this error:
gatsby can only be run for a gatsby site. Either the current
working directory does not contain a valid package.json or 'gatsby' is
not specified as a dependency
I tried to delete node_modules and install again but still giving me the same error. How can I fix this?
It seems that you are not running the commands in the proper folder.
npm start, gatsby develop or gatsby build must be triggered in the root of your Gatsby project, where the package.json is located.
Share more details about where and how are you trying to run npm start and even your project structure in order to know what's going on.

How do I resolve the error that occurred when migrating a windows local reactjs application to Linux?

I'm trying to migrate on linux centos8 an application in reactjs that runs well locally in w10 with localhost:3000 for react and localhost:3001 for nodejs.
I created in /home a folder for node in which I copied everything in the local node folder, except node_modules, I ran there npm install, I launched nodejs with the command node index.js, I tested some endpoints from postman, everything it's ok on the node side.
I created in /home a folder for the reactjs application, I copied everything in the local react folder except node_modules, I gave npm install, node_modules was created.
Then I give the command: npm start and get the error:
Failed to compile.
./src/index.css (./node_modules/css-loader/dist/cjs.js??ref--6-oneOf-3-1!./node_modules/postcss-loader/src??postcss!./src/index.css)
Error: No valid exports main found for '/home/parcare-react-test/node_modules/colorette'
and the reacjs does not start.
What can I do?
Thanks,
Does /home/paracre-react-test/node_modules/colorette exist?
My hunch is that it's installed globally (outside the project) on the original machine.
Run npm ls -g colorette to see if that package is installed globally, and npm ls colorette from the app directory to see if it's installed locally.
If it's global on the original machine, you can install it on the destination machine with npm i -g colorette (or whatever the parent package name is if it's a dependency of something else.)
If that's the issue and you don't want to install it globally on the destination machine, just install it into the app dir with npm i -D colorette. (I'm assuming it's a devDependency. If I'm wrong about that omit the -D.)

No `package.json` file found. Make sure you are running the command in a Node.js project

I am building a AngularJS file with typescript and installed tsd for typedefinitions globally. When I try to run the following command on the root of my project folder I am getting an error
I am new Angular JS using version 1.7. I am not sure if Package.json is needed for AngularJS project
Command
tsd install angular --resolve --save
Error
No package.json file found. Make sure you are running the command in a Node.js project.
package.json is required for node projects to specify metadata about project and include some important commands that may be required for the project build. First you have to install node from official website. You can google for the step by step installation. Once installed, goto your project directory and run this command. Make sure to perform "npm init" before you run the desired angular command.
Note: Ensure, node is accessible through cli
tsd is deprecated use #types node modules
npm i #types/angular --save

Need help deploying react application with netlify

Not familiar with how to use netlify. Im trying to deploy this app
https://github.com/Rshauneb/real-estate
my build command is:
npm run watch
but every time I try to deploy my site I keep getting this error.
"failed during stage 'building site'"
Any suggestions?
Mimic what Netlify is doing in the build using their build bot.
Clone your project into a clean directory from GitHub
npm install
npm run watch
If you do not get an error, you may have a global command or setting that does not get set on Netlify. Without more information, this is the only answer possible.
Here is the error I found when I did the above:
Problem #2
Watch is a command for local development, so you should not be using npm run watch as a build command on Netlify. You will need to run the command to build your site into a directory for deploy and use that directory for your "Deploy directory".

How do I install npm dependencies to build a reactjs app using VSTS?

I am trying to build a reactjs using vsts (visual studio team services). I have a very simple pipeline outlined below. Everytime I run Build it fails. It fails because it cannot find the node_modules folder. It seems they are being installed at the wrong directory location.
How can I install the node modules at the correct location? It seems to me that I need to CD into the folder after the get source command but I cannot figure out how to do change directory before the npm install command is ran.
Here is my pipeline:
get source
install dependencies
build
zip the build
Like this in vsts:
The second step Install Dependencies, which reads the package.json file and installs the node_modules, does not place the node_modules in the correct location, this causes my next step, build, to fail.
The build error says this:
I can run this manually
To run this manually using VS Code and git I run the following commands and it works every time. Here are the commands and the output.
Open working folder:
git init
git clone [web url to package here]
ls
d----- 8/30/2018 10: 56 AM CairsWebClient
cd CairsWebClient
npm install
npm start
Runs perfect.
Here are the details of the install command in vsts:
I have tried adding the following to the package.json location field. It always fails.
./CairsWebClient - Fail
/CairsWebClient - Fail cannot find C:\CairsWebClient
CairsWebClient - Error: ENOENT: no such file or directory, stat 'D:\a\1\s\CairsWebClient'
You need to specify the folder path of your project's package.json in Working folder with package.json input box, otherwise, it will uses current process's working folder.

Resources