CodeBuild failing to run CDK synth - aws-codebuild

I'm having a problem running cdk synth on codebuild, it just says: You are not authorized to perform this operation.
It's a CDK application to provision some infrastructure using #aws-cdk/app-delivery dependency to create the CI/CD pipeline. The codebuild image I'm using is: aws/codebuild/nodejs:10.1.0
The buildspec.yml is a standard one that app-delivery shares in their readme, just adding --loglevel verbose to have a better understanding of what's happenning
phases:
install:
commands:
# Installs the npm dependencies as defined by the `package.json` file
# present in the root directory of the package
# (`cdk init app --language=typescript` would have created one for you)
- npm install
build:
commands:
# Builds the CDK App so it can be synthesized
- npm run build
# Synthesizes the CDK App and puts the resulting artifacts into `dist`
- npm run cdk synth --loglevel verbose -- -o dist
artifacts:
# The output artifact is all the files in the `dist` directory
base-directory: dist
files: '**/*'
And here are the codebuild logs:
[Container] 2019/06/06 19:20:11 Running command npm run cdk synth --loglevel verbose -- -o dist
npm info it worked if it ends with ok
npm verb cli [ '/usr/local/bin/node',
npm verb cli '/usr/local/bin/npm',
npm verb cli 'run',
npm verb cli 'cdk',
npm verb cli 'synth',
npm verb cli '--loglevel',
npm verb cli 'verbose',
npm verb cli '--',
npm verb cli '-o',
npm verb cli 'dist' ]
npm info using npm#5.6.0
npm info using node#v10.1.0
npm verb run-script [ 'precdk', 'cdk', 'postcdk' ]
npm info lifecycle dvi-infrastructure-cdk#0.1.0~precdk: dvi-infrastructure-cdk#0.1.0
npm info lifecycle dvi-infrastructure-cdk#0.1.0~cdk: dvi-infrastructure-cdk#0.1.0
> dvi-infrastructure-cdk#0.1.0 cdk /codebuild/output/src891487954/src
> cdk "synth" "-o" "dist"
You are not authorized to perform this operation.
npm verb lifecycle dvi-infrastructure-cdk#0.1.0~cdk: unsafe-perm in lifecycle true
npm verb lifecycle dvi-infrastructure-cdk#0.1.0~cdk: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/codebuild/output/src891487954/src/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
npm verb lifecycle dvi-infrastructure-cdk#0.1.0~cdk: CWD: /codebuild/output/src891487954/src
npm info lifecycle dvi-infrastructure-cdk#0.1.0~cdk: Failed to exec cdk script
npm verb stack Error: dvi-infrastructure-cdk#0.1.0 cdk: `cdk "synth" "-o" "dist"`
npm verb stack Exit status 1
npm verb stack at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:285:16)
npm verb stack at EventEmitter.emit (events.js:182:13)
npm verb stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
npm verb stack at ChildProcess.emit (events.js:182:13)
npm verb stack at maybeClose (internal/child_process.js:957:16)
npm verb stack at Process.ChildProcess._handle.onexit (internal/child_process.js:246:5)
npm verb pkgid dvi-infrastructure-cdk#0.1.0
npm verb cwd /codebuild/output/src891487954/src
npm verb Linux 4.14.114-83.126.amzn1.x86_64
npm verb argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "cdk" "synth" "--loglevel" "verbose" "--" "-o" "dist"
npm verb node v10.1.0
npm verb npm v5.6.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! dvi-infrastructure-cdk#0.1.0 cdk: `cdk "synth" "-o" "dist"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the dvi-infrastructure-cdk#0.1.0 cdk script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm verb exit [ 1, true ]
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2019-06-06T19_20_13_082Z-debug.log
[Container] 2019/06/06 19:20:13 Command did not exit successfully npm run cdk synth --loglevel verbose -- -o dist exit status 1
[Container] 2019/06/06 19:20:13 Phase complete: BUILD State: FAILED
[Container] 2019/06/06 19:20:13 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: npm run cdk synth --loglevel verbose -- -o dist. Reason: exit status 1

I've been able to check which was the error by running npm run cdk synth -- -v -o dist command in my buildspec.yml. With that I got the following error:
Some context information is missing. Fetching...
Reading AZs for 244496089465:us-west-2
Using default AWS SDK credentials for account 244496089465
You are not authorized to perform this operation.
UnauthorizedOperation: You are not authorized to perform this operation.
at Request.extractError (/codebuild/output/src133069252/src/node_modules/aws-sdk/lib/services/ec2.js:50:35)
at Request.callListeners (/codebuild/output/src133069252/src/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
at Request.emit (/codebuild/output/src133069252/src/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
at Request.emit (/codebuild/output/src133069252/src/node_modules/aws-sdk/lib/request.js:683:14)
at Request.transition (/codebuild/output/src133069252/src/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/codebuild/output/src133069252/src/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /codebuild/output/src133069252/src/node_modules/aws-sdk/lib/state_machine.js:26:10
at Request.<anonymous> (/codebuild/output/src133069252/src/node_modules/aws-sdk/lib/request.js:38:9)
at Request.<anonymous> (/codebuild/output/src133069252/src/node_modules/aws-sdk/lib/request.js:685:12)
at Request.callListeners (/codebuild/output/src133069252/src/node_modules/aws-sdk/lib/sequential_executor.js:116:18)
So, by adding the following permission ec2:DescribeAvailabilityZones into the codebuild role solved my problem

Related

Getting Bad Request (Http 400) when using npm dist-tag with Nexus 3.19.1-01

We are running Nexus OSS 3.19.1-01 (CentOS7 with OpenJdk 1.8.0_222-b10) with npm repository. Everything works fine except the npm dist-tag feature which should now work with version >3.19.
$ npm publish <pkg> --tag bla #--> works
$ npm install <pkg>#bla #--> works
$ npm dist-tag ls <pkg> #--> works
$ npm dist-tag rm --verbose #myscope/mypackage foo
npm info it worked if it ends with ok
npm verb cli [
npm verb cli '/usr/bin/node',
npm verb cli '/usr/local/bin/npm',
npm verb cli 'dist-tag',
npm verb cli 'rm',
npm verb cli '--verbose',
npm verb cli '#myscope/mypackage',
npm verb cli 'foo'
npm verb cli ]
npm info using npm#6.13.1
npm info using node#v12.13.0
npm verb npm-session 3b193197390df1cf
npm verb dist-tag del snapshot from #myscope/mypackage
npm http fetch GET 200 https://nexus.example.com/repository/npm-group/-/package/#myscope%2fmypackage/dist-tags 1396ms
npm http fetch DELETE 400 https://nexus.example.com/repository/npm-group/-/package/#myscope%2fmypackage/dist-tags/foo 9ms
npm verb stack Error: 400 Bad Request - DELETE https://nexus.example.com/repository/npm-group/-/package/#myscope%2fmypackage/dist-tags/foo
npm verb stack at /usr/local/lib/node_modules/npm/node_modules/npm-registry-fetch/check-response.js:104:15
npm verb stack at processTicksAndRejections (internal/process/task_queues.js:93:5)
npm verb statusCode 400
npm verb pkgid #myscope/mypackage#latest
npm verb cwd /home/myname/path-to-code/mypackage/client
npm verb Linux 5.3.11-300.fc31.x86_64
npm verb argv "/usr/bin/node" "/usr/local/bin/npm" "dist-tag" "rm" "--verbose" "#myscope/mypackage" "foo"
npm verb node v12.13.0
npm verb npm v6.13.1
npm ERR! code E400
npm ERR! 400 Bad Request - DELETE https://nexus.example.com/repository/npm-group/-/package/#myscope%2fmypackage/dist-tags/foo
npm verb exit [ 1, true ]
npm timing npm Completed in 1730ms
npm ERR! A complete log of this run can be found in:
npm ERR! /home/myname/.npm/_logs/2019-11-20T13_02_41_234Z-debug.log
$ npm dist-tag add #myscope/mypackage#0.1.0 bar
# did not work, same error as above
No additional log messages in nexus log.
Any idea?
I'm afraid it won't work for you, because you're running your commands against npm group repository. Both npm dist-tag add and npm dist-tag rm work only for hosted repositories as of NXRM 3.19.1. However, npm dist-tag ls is supported by all types of repositories (since 3.19.0).

Npm install : FetchError: request to http://registry.npmjs.org/... failed, reason: read ECONNRESET

Trying to install any node package using npm hangs for about 5 mins then gives a ECONNRESET network error. I have been using npm for other projects recently and it worked fine but now will not work for any project(Including clean npm init)
npm i ws
This is on a Raspberry pi 3 running on my home network with no proxy requirements. All other machines both linux and windows are working fine.
npm -v = 6.4.1
I have tried the following:
npm i ws This gives me the ECONNRESET error (See below)
Curl https://registry.npmjs.org/
& Curl https://registry.npmjs.org/ws
Both return the correct json response
Removing any proxy settings
npm config rm proxy
npm config rm https-proxy
npm config set registry http://registry.npmjs.org/
Restarting etc
Full Error log:
npm i ws --save --verbose
npm info it worked if it ends with ok
npm verb cli [ '/home/pi/.nvm/versions/node/v8.16.0/bin/node',
npm verb cli '/home/pi/.nvm/versions/node/v8.16.0/bin/npm',
npm verb cli 'i',
npm verb cli 'ws',
npm verb cli '--save',
npm verb cli '--verbose' ]
npm info using npm#6.4.1
npm info using node#v8.16.0
npm verb npm-session 0a9bedb5def7f4a1
npm timing stage:rollbackFailedOptional Completed in 6ms
npm timing stage:runTopLevelLifecycles Completed in 1146975ms
npm verb type system
npm verb stack FetchError: request to http://registry.npmjs.org/ws failed, reason: read ECONNRESET
npm verb stack at ClientRequest.req.on.err (/home/pi/.nvm/versions/node/v8.16.0/lib/node_modules/npm/node_modules/node-fetch-npm/src/index.js:68:14)
npm verb stack at emitOne (events.js:116:13)
npm verb stack at ClientRequest.emit (events.js:211:7)
npm verb stack at Socket.socketErrorListener (_http_client.js:401:9)
npm verb stack at emitOne (events.js:116:13)
npm verb stack at Socket.emit (events.js:211:7)
npm verb stack at emitErrorNT (internal/streams/destroy.js:66:8)
npm verb stack at _combinedTickCallback (internal/process/next_tick.js:139:11)
npm verb stack at process._tickCallback (internal/process/next_tick.js:181:9)
npm verb cwd /home/pi/projects/picamera/node_server
npm verb Linux 4.19.37-v7+
npm verb argv "/home/pi/.nvm/versions/node/v8.16.0/bin/node" "/home/pi/.nvm/versions/node/v8.16.0/bin/npm" "i" "ws" "--save" "--verbose"
npm verb node v8.16.0
npm verb npm v6.4.1
npm ERR! code ECONNRESET
npm ERR! errno ECONNRESET
npm ERR! network request to http://registry.npmjs.org/ws failed, reason: read ECONNRESET
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly. See: 'npm help config'
npm verb exit [ 1, true ]
npm timing npm Completed in 1148813ms
npm ERR! A complete log of this run can be found in:
npm ERR! /home/pi/.npm/_logs/2019-05-10T23_28_17_769Z-debug.log
First check following thing:
ping registry.npmjs.org
You will get to know the IP address from that like below:
PING registry.npmjs.org (104.16.20.35) 56(84) bytes of data.
Then
sudo vi /etc/hosts
104.16.20.35 registry.npmjs.org
Then try to do following
npm install

npm prune bad PATH? Failed to exec install script

When I run npm prune I get the following (verbose) error
npm info lifecycle elm#0.19.0-bugfix2~install: elm#0.19.0-bugfix2
> elm#0.19.0-bugfix2 install node_modules/elm
> binwrap-install
sh: 1: binwrap-install: not found
npm verb lifecycle elm#0.19.0-bugfix2~install: unsafe-perm in lifecycle true
npm verb lifecycle elm#0.19.0-bugfix2~install: PATH: /tmp/build/.heroku/node/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/tmp/build/apps/web/node_modules/elm/node_modules/.bin:/tmp/build/.heroku/node/bin:/tmp/build/.platform_tools:/tmp/build/.platform_tools/erlang/bin:/tmp/build/.platform_tools/elixir/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
npm verb lifecycle elm#0.19.0-bugfix2~install: CWD: node_modules/elm
npm info lifecycle elm#0.19.0-bugfix2~install: Failed to exec install script
npm timing action:install Completed in 79ms
npm verb unlock done using /app/.npm/_locks/staging-4628ace6b39e4e32.lock for /tmp/build/apps/web/node_modules/.staging
npm timing stage:rollbackFailedOptional Completed in 62ms
npm timing stage:runTopLevelLifecycles Completed in 6364ms
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.2.4 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm verb notsup SKIPPING OPTIONAL DEPENDENCY: Valid OS: darwin
npm verb notsup SKIPPING OPTIONAL DEPENDENCY: Valid Arch: any
npm verb notsup SKIPPING OPTIONAL DEPENDENCY: Actual OS: linux
npm verb notsup SKIPPING OPTIONAL DEPENDENCY: Actual Arch: x64
npm verb stack Error: elm#0.19.0-bugfix2 install: `binwrap-install`
npm verb stack spawn ENOENT
npm verb stack at ChildProcess.<anonymous> (/tmp/build/.heroku/node/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:48:18)
npm verb stack at ChildProcess.emit (events.js:182:13)
npm verb stack at maybeClose (internal/child_process.js:961:16)
npm verb stack at Process.ChildProcess._handle.onexit (internal/child_process.js:248:5)
npm verb pkgid elm#0.19.0-bugfix2
npm verb cwd /tmp/build/apps/web
npm verb Linux 4.15.0-36-generic
npm verb argv "/tmp/build/.heroku/node/bin/node" "/tmp/build/.heroku/node/bin/npm" "prune" "--verbose"
npm verb node v10.7.0
npm verb npm v6.1.0
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! elm#0.19.0-bugfix2 install: `binwrap-install`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the elm#0.19.0-bugfix2 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm verb exit [ 1, true ]
npm timing npm Completed in 6866ms
It can't find binwrap-install and I think it's because the PATH is incorrect. I verified that the binary exists here.
ls -l node_modules/.bin/binwrap-install
lrwxrwxrwx 1 js js 30 Nov 9 23:48 node_modules/.bin/binwrap-install -> ../binwrap/bin/binwrap-install
But, the PATH in the error output above does not include
node_modules/.bin
Instead it includes
node_modules/elm/node_modules/.bin
Higher up in the verbose logging, I saw this which might be relevant.
npm info linkStuff binwrap#0.2.0
npm verb linkBins [ { 'binwrap-install': 'bin/binwrap-install',
npm verb linkBins 'binwrap-prepare': 'bin/binwrap-prepare',
npm verb linkBins 'binwrap-test': 'bin/binwrap-test' },
npm verb linkBins '/tmp/build/apps/web/node_modules/elm-format/node_modules/.bin',
npm verb linkBins false ]
npm info linkStuff fstream#0.1.31
npm info linkStuff unzip#0.1.11
npm info linkStuff binwrap#0.1.4
npm verb linkBins [ { 'binwrap-install': 'bin/binwrap-install',
npm verb linkBins 'binwrap-test': 'bin/binwrap-test' },
npm verb linkBins '/tmp/build/apps/web/node_modules/.bin',
npm verb linkBins false ]
Is this expected behavior or is it a bug somewhere? Is there something I can do to make the PATH for npm prune include the node_modules/.bin folder?
Try switching to Elm 0.19.1.
I was having this same issue and now with Elm 0.19.1 it seems to have stopped happening. The latest npm installer no longer relies on binwrap, which I think may have been the issue.
My initial command was:
$ sudo npm install elm -g
The log was:
npm ERR! elm#0.19.0-bugfix2 install: binwrap-install
I attempted to remove npm.
Then I took a drastic measure:
$ cd /usr/local/lib
$ sudo rm -R node_modules
Then:
$ sudo apt install npm
Then:
$ sudo apt install elm -g
I now have elm 0.19.0 installed.

npm run dev causes errors on fresh laravel 5.6.x installation

I'm busy learning Laravel and run into a problem when i want to run npm run dev
First some background information:
Laravel version 5.6.22
npm version 6.01
node version 8.10.0
OS Ubuntu 18.4 LTS
PHP 7.2.5
Composer v 1.6.3
Executed steps:
Created a new laravel project sudo composer create-project --prefer-dist laravel/laravel npmtest
Grant all permissions (i'm aware of the security risks with 777 but did this just to test) sudo chmod -R 777 /var/www/npmtest
did a sudo composer install in the project root
followed by sudo npm install (already some error noticed)
Result of sudo npm install
npm WARN deprecated gulp-util#3.0.8: gulp-util is deprecated - replace it, following the guidelines at https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5
> node-sass#4.9.0 install /var/www/npmtest/node_modules/node-sass
> node scripts/install.js
Unable to save binary /var/www/npmtest/node_modules/node-sass/vendor/linux-x64-57 : { Error: EACCES: permission denied, mkdir '/var/www/npmtest/node_modules/node-sass/vendor'
at Object.fs.mkdirSync (fs.js:885:18)
at sync (/var/www/npmtest/node_modules/mkdirp/index.js:71:13)
at Function.sync (/var/www/npmtest/node_modules/mkdirp/index.js:77:24)
at checkAndDownloadBinary (/var/www/npmtest/node_modules/node-sass/scripts/install.js:114:11)
at Object.<anonymous> (/var/www/npmtest/node_modules/node-sass/scripts/install.js:157:1)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
errno: -13,
code: 'EACCES',
syscall: 'mkdir',
path: '/var/www/npmtest/node_modules/node-sass/vendor' }
> uglifyjs-webpack-plugin#0.4.6 postinstall /var/www/npmtest/node_modules/webpack/node_modules/uglifyjs-webpack-plugin
> node lib/post_install.js
> node-sass#4.9.0 postinstall /var/www/npmtest/node_modules/node-sass
> node scripts/build.js
Building: /usr/bin/node /var/www/npmtest/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
gyp info it worked if it ends with ok
gyp verb cli [ '/usr/bin/node',
gyp verb cli '/var/www/npmtest/node_modules/node-gyp/bin/node-gyp.js',
gyp verb cli 'rebuild',
gyp verb cli '--verbose',
gyp verb cli '--libsass_ext=',
gyp verb cli '--libsass_cflags=',
gyp verb cli '--libsass_ldflags=',
gyp verb cli '--libsass_library=' ]
gyp info using node-gyp#3.6.2
gyp info using node#8.10.0 | linux | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` succeeded python2 /usr/bin/python2
gyp verb check python version `/usr/bin/python2 -c "import platform; print(platform.python_version());"` returned: "2.7.15rc1\n"
gyp verb get node dir no --target version specified, falling back to host node version: 8.10.0
gyp verb command install [ '8.10.0' ]
gyp verb install input version string "8.10.0"
gyp verb install installing version: 8.10.0
gyp verb install --ensure was passed, so won't reinstall if already installed
gyp verb install version is already installed, need to check "installVersion"
gyp verb got "installVersion" 9
gyp verb needs "installVersion" 9
gyp verb install version is good
gyp verb get node dir target node version installed: 8.10.0
gyp verb build dir attempting to create "build" dir: /var/www/npmtest/node_modules/node-sass/build
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/var/www/npmtest/node_modules/node-sass/build'
gyp ERR! System Linux 4.15.0-20-generic
gyp ERR! command "/usr/bin/node" "/var/www/npmtest/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /var/www/npmtest/node_modules/node-sass
gyp ERR! node -v v8.10.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
Build failed with error code: 1
npm WARN ajv-keywords#3.2.0 requires a peer of ajv#^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.2.4 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass#4.9.0 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass#4.9.0 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/roge/.npm/_logs/2018-05-18T13_53_01_126Z-debug.log
As i had no idea what to do with the errors and noticed that some of them go over permissions and permissions of node-modules where not 777, probably because executing npm install as root, i did:
sudo chmod -R 777 /var/www/npmtest again
followed by sudo npm install again
Result:
npm WARN deprecated gulp-util#3.0.8: gulp-util is deprecated - replace it, following the guidelines at https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5
> node-sass#4.9.0 install /var/www/npmtest/node_modules/node-sass
> node scripts/install.js
Unable to save binary /var/www/npmtest/node_modules/node-sass/vendor/linux-x64-57 : { Error: EACCES: permission denied, mkdir '/var/www/npmtest/node_modules/node-sass/vendor'
at Object.fs.mkdirSync (fs.js:885:18)
at sync (/var/www/npmtest/node_modules/mkdirp/index.js:71:13)
at Function.sync (/var/www/npmtest/node_modules/mkdirp/index.js:77:24)
at checkAndDownloadBinary (/var/www/npmtest/node_modules/node-sass/scripts/install.js:114:11)
at Object.<anonymous> (/var/www/npmtest/node_modules/node-sass/scripts/install.js:157:1)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
errno: -13,
code: 'EACCES',
syscall: 'mkdir',
path: '/var/www/npmtest/node_modules/node-sass/vendor' }
> uglifyjs-webpack-plugin#0.4.6 postinstall /var/www/npmtest/node_modules/webpack/node_modules/uglifyjs-webpack-plugin
> node lib/post_install.js
> node-sass#4.9.0 postinstall /var/www/npmtest/node_modules/node-sass
> node scripts/build.js
Building: /usr/bin/node /var/www/npmtest/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
gyp info it worked if it ends with ok
gyp verb cli [ '/usr/bin/node',
gyp verb cli '/var/www/npmtest/node_modules/node-gyp/bin/node-gyp.js',
gyp verb cli 'rebuild',
gyp verb cli '--verbose',
gyp verb cli '--libsass_ext=',
gyp verb cli '--libsass_cflags=',
gyp verb cli '--libsass_ldflags=',
gyp verb cli '--libsass_library=' ]
gyp info using node-gyp#3.6.2
gyp info using node#8.10.0 | linux | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` succeeded python2 /usr/bin/python2
gyp verb check python version `/usr/bin/python2 -c "import platform; print(platform.python_version());"` returned: "2.7.15rc1\n"
gyp verb get node dir no --target version specified, falling back to host node version: 8.10.0
gyp verb command install [ '8.10.0' ]
gyp verb install input version string "8.10.0"
gyp verb install installing version: 8.10.0
gyp verb install --ensure was passed, so won't reinstall if already installed
gyp verb install version is already installed, need to check "installVersion"
gyp verb got "installVersion" 9
gyp verb needs "installVersion" 9
gyp verb install version is good
gyp verb get node dir target node version installed: 8.10.0
gyp verb build dir attempting to create "build" dir: /var/www/npmtest/node_modules/node-sass/build
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/var/www/npmtest/node_modules/node-sass/build'
gyp ERR! System Linux 4.15.0-20-generic
gyp ERR! command "/usr/bin/node" "/var/www/npmtest/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /var/www/npmtest/node_modules/node-sass
gyp ERR! node -v v8.10.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
Build failed with error code: 1
npm WARN ajv-keywords#3.2.0 requires a peer of ajv#^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.2.4 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass#4.9.0 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass#4.9.0 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/roge/.npm/_logs/2018-05-18T13_53_01_126Z-debug.log
As i still could not find a solution for the errors, i tried to execute sudo npm run dev (and without sudo) what didn't work off course
result:
> # dev /var/www/npmtest
> npm run development
> # development /var/www/npmtest
> cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js
module.js:549
throw err;
^
Error: Cannot find module '/var/www/npmtest/node_modules/laravel-mix/setup/webpack.config.js'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at requireConfig (/var/www/npmtest/node_modules/webpack/bin/convert-argv.js:97:18)
at /var/www/npmtest/node_modules/webpack/bin/convert-argv.js:104:17
at Array.forEach (<anonymous>)
at module.exports (/var/www/npmtest/node_modules/webpack/bin/convert-argv.js:102:15)
at yargs.parse (/var/www/npmtest/node_modules/webpack/bin/webpack.js:171:41)
at Object.Yargs.self.parse (/var/www/npmtest/node_modules/yargs/yargs.js:533:18)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! # development: `cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the # development script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/roge/.npm/_logs/2018-05-18T14_01_02_924Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! # dev: `npm run development`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the # dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/roge/.npm/_logs/2018-05-18T14_01_02_953Z-debug.log
After Google a few hours and trying:
https://github.com/JeffreyWay/laravel-mix/issues/533 and https://github.com/JeffreyWay/laravel-mix/issues/1072 and few more i have no idea where to continue.
For some magic reason is npm run dev working in one of my projects. Its the same Laravel version and i have really no idea what i did else there than in the (multiple) new projects i tried to get working...
Did i forget something or something wrong? Hope that someone can help me! Thanks in advance...
I solved the same problem
sudo apt-get install libpng-dev
npm install -g pngquant-bin

On Premise Agent does not download all NPM packages

Edit: 2018-02-28 - add screen shot of build definition
I am having a problem with an on premise VSTS Agent. When 'npm install' runs, it only installs about 20% of the packages. the command does not error out. If I run the same NPM install command when I remote into the machine all the packages are installed. I used the same steps manually that are in the Visual Studio Team Services Hosted Images scripts. Specifically Install-NodeLts.ps1
I need to get the local agent running so our builds will complete.
npm/5.6.0 node/v8.9.4 win32 x64
You can see below it says: 'added 559 packages in 37.875s', but when run npm install from command line via RDP, it installs 2419 packages.
I have tried:
re-install NPM as a task
run npm install twice as two different tasks
run npm install from a command task
run agent as my same user account
Partial output log:
2018-02-27T21:30:59.6386335Z ##[section]Starting: npm install
2018-02-27T21:30:59.6396849Z ==============================================================================
2018-02-27T21:30:59.6397102Z Task : npm
2018-02-27T21:30:59.6397398Z Description : Install and publish npm packages, or run an npm command. Supports npmjs.com and authenticated registries like Package Management.
2018-02-27T21:30:59.6397690Z Version : 1.0.10
2018-02-27T21:30:59.6397884Z Author : Microsoft Corporation
2018-02-27T21:30:59.6398144Z Help : [More Information](https://go.microsoft.com/fwlink/?LinkID=613746)
2018-02-27T21:30:59.6398400Z ==============================================================================
2018-02-27T21:31:00.7066189Z [command]C:\WINDOWS\system32\cmd.exe /D /S /C ""C:\Program Files\nodejs\npm.cmd" --version"
2018-02-27T21:31:02.6879301Z 5.6.0
2018-02-27T21:31:07.0100259Z [command]C:\WINDOWS\system32\cmd.exe /D /S /C ""C:\Program Files\nodejs\npm.cmd" config list"
2018-02-27T21:31:09.1937476Z npm info it worked if it ends with ok
2018-02-27T21:31:09.1938350Z npm verb cli [ 'C:\\Program Files\\nodejs\\node.exe',
2018-02-27T21:31:09.1938614Z npm verb cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
2018-02-27T21:31:09.1938859Z npm verb cli 'prefix',
2018-02-27T21:31:09.1939038Z npm verb cli '-g' ]
2018-02-27T21:31:09.1939210Z npm info using npm#5.6.0
2018-02-27T21:31:09.1939414Z npm info using node#v8.9.4
2018-02-27T21:31:09.1939594Z npm verb exit [ 0, true ]
2018-02-27T21:31:09.1939806Z npm info ok
2018-02-27T21:31:09.1940065Z npm info it worked if it ends with ok
2018-02-27T21:31:09.1940314Z npm verb cli [ 'C:\\Program Files\\nodejs\\node.exe',
2018-02-27T21:31:09.1940577Z npm verb cli 'C:\\npm\\prefix\\node_modules\\npm\\bin\\npm-cli.js',
2018-02-27T21:31:09.1940790Z npm verb cli 'config',
2018-02-27T21:31:09.1941046Z npm verb cli 'list' ]
2018-02-27T21:31:09.1941258Z npm info using npm#5.6.0
2018-02-27T21:31:09.1941470Z npm info using node#v8.9.4
2018-02-27T21:31:09.1941711Z npm verb exit [ 0, true ]
2018-02-27T21:31:09.1941956Z npm info ok
2018-02-27T21:31:09.1942165Z ; cli configs
2018-02-27T21:31:09.1942384Z metrics-registry = "https://registry.npmjs.org/"
2018-02-27T21:31:09.1942647Z scope = ""
2018-02-27T21:31:09.1942849Z user-agent = "npm/5.6.0 node/v8.9.4 win32 x64"
2018-02-27T21:31:09.1942977Z
2018-02-27T21:31:09.1943141Z ; environment configs
2018-02-27T21:31:09.1943350Z cache = "C:\\npm\\cache"
2018-02-27T21:31:09.1943529Z loglevel = "verbose"
2018-02-27T21:31:09.1943712Z prefix = "C:\\npm\\prefix"
2018-02-27T21:31:09.1943927Z userconfig = "D:\\VSTSAgent\\vsts-agent-win-x64-2.129.1\\_work\\2\\npm\\187.npmrc"
2018-02-27T21:31:09.1944096Z
2018-02-27T21:31:09.1944268Z ; builtin config undefined
2018-02-27T21:31:09.1944399Z
2018-02-27T21:31:09.1944626Z ; node bin location = C:\Program Files\nodejs\node.exe
2018-02-27T21:31:09.1944941Z ; cwd = D:\VSTSAgent\vsts-agent-win-x64-2.129.1\_work\2\s\Web
2018-02-27T21:31:09.1945215Z ; HOME = C:\Users\bolducp
2018-02-27T21:31:09.1945445Z ; "npm config ls -l" to show all defaults.
2018-02-27T21:31:09.1945592Z
2018-02-27T21:31:09.1947815Z [command]C:\WINDOWS\system32\cmd.exe /D /S /C ""C:\Program Files\nodejs\npm.cmd" install"
2018-02-27T21:31:50.2618021Z npm info it worked if it ends with ok
2018-02-27T21:31:50.2618358Z
2018-02-27T21:31:50.2623471Z > react-bootstrap-select#0.14.0 postinstall D:\VSTSAgent\vsts-agent-win-x64-2.129.1\_work\2\s\Web\node_modules\react-bootstrap-select
2018-02-27T21:31:50.2624421Z npm verb cli [ 'C:\\Program Files\\nodejs\\node.exe',
2018-02-27T21:31:50.2624674Z > jsx jsx/ dist/
2018-02-27T21:31:50.2624944Z npm verb cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
2018-02-27T21:31:50.2625391Z
2018-02-27T21:31:50.2625873Z ["Select"]
2018-02-27T21:31:50.2627029Z added 559 packages in 37.875s
2018-02-27T21:31:50.2636988Z npm verb cli 'prefix',
2018-02-27T21:31:50.2637434Z npm verb cli '-g' ]
2018-02-27T21:31:50.2639621Z npm info using npm#5.6.0
2018-02-27T21:31:50.2639731Z npm info using node#v8.9.4
2018-02-27T21:31:50.2639837Z npm verb exit [ 0, true ]
2018-02-27T21:31:50.2640063Z npm info ok
2018-02-27T21:31:50.2640199Z npm info it worked if it ends with ok
2018-02-27T21:31:50.2640352Z npm verb cli [ 'C:\\Program Files\\nodejs\\node.exe',
2018-02-27T21:31:50.2640480Z npm verb cli 'C:\\npm\\prefix\\node_modules\\npm\\bin\\npm-cli.js',
2018-02-27T21:31:50.2640597Z npm verb cli 'install' ]
2018-02-27T21:31:50.2640700Z npm info using npm#5.6.0
2018-02-27T21:31:50.2640835Z npm info using node#v8.9.4
2018-02-27T21:31:50.2640945Z npm verb npm-session 7bedb538a9b4e7b7
2018-02-27T21:31:50.2641065Z npm info lifecycle company-project#1.0.0~preinstall: company-project#1.0.0
2018-02-27T21:31:50.2641230Z npm http fetch GET 304 https://registry.npmjs.org/moment 375ms (from cache)
...
2018-02-27T21:31:50.3412460Z npm verb exit [ 0, true ]
2018-02-27T21:31:50.3412559Z npm info ok
2018-02-27T21:31:50.3416231Z ##[section]Finishing: npm install
When setting up the hosted agent, I had modified the build definition to include an environment variable NODE_ENV=production. When the NODE_ENV environment variable is set to production, npm will not install modules listed in devDependencies.