My build will not finish because it fails on the NPM step of Ng Build
Here is the build process and error:
npm install -g #angular/cli
npm install
ng build (or ng build --prod) depending on your preference
Publish Artifacts
On step 3, I get the Error: Npm failed with return code: 1
Details around user-agent = "npm/6.5.0 node/v10.15.0 win32 x64"
My package.json file exists in the repository and I've tried having it look specifically in that file or in the directory.
It seems to fail on this line of cold in the build on step 3 "command]C:\windows\system32\cmd.exe /D /S /C "C:\npm\prefix\npm.cmd ng build""
Any help would be appreciated.
Related
I need your help
I was trying to run my cypress test cases which I generally run using command
"npx cypress run"
so I tried to have the same command in tasks when I created Azure pipeline
after NPM Install
I even tried installing npx via
npm task and custom command "npm install nx"
and this causing the below issue so can anyone suggest to me how to proceed in this case
"##[warning]Couldn't find a debug log in the cache or working directory
##[error]Error: Npm failed with return code: 1
"
From the error screenshot, it shows that you are using the Npm Task and running the command: npm npm install nx.
The command is invalid.
To solve this issue, you need to remove the npm in the NPM task -> Command and arguments .
Refer to the following sample:
YAML Pipeline:
- task: Npm#1
displayName: 'npm custom'
inputs:
command: custom
verbose: false
customCommand: 'install nx'
Classic Pipeline:
After
npm run build
When serving with
npm run serve -s dist
This dependency was not found:
/Users/zarpio/code/vuejs/p3-admin/dist in multi (webpack)-dev-server/client?http://192.168.31.234:8081/sockjs-node (webpack)/hot/dev-server.js ./dist, multi (webpack)/hot/dev-server.js (webpack)-dev-server/client?http://192.168.31.234:8081/sockjs-node ./dist
To install it, you can run: npm install --save /Users/zarpio/code/vuejs/p3-admin/dist
I believe there is a dependency your project has which you have not installed. Run npm install to install the necessary dependencies. sometimes npm gets messed up and i need to delete the entire node modules folder and then run npm install to get a fresh node modules setup.
just to clear some things up.the default vue cli configuration is that npm run serve will run your app live locally. the npm run build compiles your app into the dist folder which you then can serve from your server ( or something like the live server extension in VS code)
I'm new to CI Builds in VSTS and as a result, having a struggle with a specific npm task.
In the Build process, after the first five tasks execute, I use an npm task with a custom command. This command executes webpack script defined in my package.json
npm run prod
"prod": "webpack --env.NODE_ENV=production --config webpack.config.js --progress"
When this task runs, it errors with the following message
Error: Npm failed with return code: 1
Thoughts? Suggestions? This is trying me a little insane, I'm sure there's a simple solution :)
Replace npm run prod to run prod in command and arguments box.
I've defined some scripts in my package.json, e.g.,
"config": {
"source": "./assets/stylesheets/civica-styles.scss",
"dist": "./dist/civica-styles.css",
"minCss": "./dist/civica-styles.min.css"
},
"scripts": {
"transpile": "cross-var node-sass $npm_package_config_source $npm_package_config_dist",
"minify": "cross-var cleancss -o $npm_package_config_minCss $npm_package_config_dist"
}
I can run these at the command line as follows
npm run transpile
I have set up a build in VSTS that performs the following initial tasks:
Get Sources (get my code from the repo)
npm install (installs the
packages defined in my package.json)
Now I want to add a task that runs my transpile defined in package.json, so I added the following npm custom task
Display name => npm transpile
Command => custom
Command and arguments => run transpile
However the build fails with
2017-08-01T10:01:42.5125804Z ##[section]Starting: npm custom
2017-08-01T10:01:42.5125804Z ==============================================================================
2017-08-01T10:01:42.5125804Z Task : npm
2017-08-01T10:01:42.5125804Z Description : Install and publish npm packages, or run an npm command. Supports npmjs.com and authenticated registries like Package Management.
2017-08-01T10:01:42.5125804Z Version : 1.0.3
2017-08-01T10:01:42.5125804Z Author : Microsoft Corporation
2017-08-01T10:01:42.5125804Z Help : [More Information](https://go.microsoft.com/fwlink/?LinkID=613746)
2017-08-01T10:01:42.5125804Z ==============================================================================
2017-08-01T10:01:43.3515881Z ##[error]TypeError: Cannot read property 'trim' of null
2017-08-01T10:01:43.3565858Z ##[section]Finishing: npm custom
Any ideas of how to execute an npm run script from a VSTS build task?
Check Working folder with package.json box of npm task. It is the folder path not the file, you can use $(Build.SourcesDirectory).
Running npm from the PowerShell task worked for me.
Set type to "Inline"
Write your task in the "Script" box eg. npm run test
Make sure "Working Directory" is set to the package.json folder under "Advanced"
I'm currently using npm install to install all packages for an Angular2 project CI project, however this step has started to increase the time it takes build agents to build the project. I would like to get build run times down for our CI pipeline by using the npm-cache command, however I keep getting failed attempts at running the command through the build agent.
I have tried using a Command Line step with the following:
This result in the error File name doesn't indicate a full path to a executable file.
I have also tried added an npm step:
Which results in the following:
2017-06-14T13:01:13.2274922Z [command]C:\Program Files\nodejs\npm.cmd cache install
2017-06-14T13:01:19.8609829Z npm ERR! Usage: npm cache add tarball file
2017-06-14T13:01:19.8630626Z npm ERR! npm cache add folder
2017-06-14T13:01:19.8630626Z npm ERR! npm cache add tarball url
2017-06-14T13:01:19.8640981Z npm ERR! npm cache add git url
2017-06-14T13:01:19.8651863Z npm ERR! npm cache add name#version
2017-06-14T13:01:19.8661607Z npm ERR! npm cache ls path
2017-06-14T13:01:19.8672137Z npm ERR! npm cache clean pkg#version
What is the correct way to call npm cache from Team Services?
You need to install npm-cache package first, then call npm-cache command via command line task.
Add npm task (npm command: install; arguments: npm-cache -g)
Add Command Line task (Tool: C:\\Windows\\ServiceProfiles\\NetworkService\\AppData\\Roaming\\npm\\npm-cache; Arguments:install; Working folder: $(Build.SourcesDirectory))
Node: Previous steps uses the private build agent that running as service with NetworkService account. You can add C:\\Windows\\ServiceProfiles\\NetworkService\\AppData\\Roaming\\npm to system environment variable (restart machine is needed) and call npm-cache command directly.
You also can change build agent account to use your account (by default C:\Users\[user name]\AppData\Roaming\npm has added to user environment variable), then call npm-cache command after install npm-cache package with -g argument)
On the other hand, host agent won’t cache the packages, so it is useless if you are using hosted agent.