npm-scripts

NPM Run Build Always Builds Production and Never Development

笑着哭i 提交于 2019-12-10 21:57:37
问题 On an inherited project I have, I am trying to get the build command to build a version other than Production . I have attempted to change the alias in the script section in package.json to pass in extra variables such as --dev and --configuration=dev to no avail. The project has these json data files: env.dev env.development env.production with the package.json has this build alias build:dev which I run npm run build:dev : "scripts": { "start": "NODE_ENV=dev && react-scripts start", … "build

Match multiple file extensions in npm script

空扰寡人 提交于 2019-12-10 13:25:32
问题 I have an npm script where I want to match both ts and tsx file extensions... something like below: "test": "mocha ..... app/test/**/*.spec.{ts,tsx}" However, the above syntax doesn't work. What's the correct syntax for doing this? 回答1: Your pattern is correct. Your problem is that your shell is attempting to expand your glob for you instead of letting mocha expand it. To fix this, you need to double-quote your glob (note that double-quotes must be JSON-escaped with \ ): "test": "mocha .....

Gitlab CI does not execute npm scripts

江枫思渺然 提交于 2019-12-10 13:19:45
问题 I try to make a CI script running on a gitlab runner. What I want is simple: First the npm install command should be executed to fetch all the required npm packages. After that the npm test and npm run build should be executed. The .gitblab-ci.yml script looks as follow: before_script: - cd my/folder/ - npm install --silent stages: - test - build run_tests: script: - npm test stage: test build: script: - npm run build stage: build Unfortunatly only the npm install gets executed twice. And

NPM run parallel task, but wait until resource is available to run second task

佐手、 提交于 2019-12-09 11:37:15
问题 In npm, how can I run two or more parallel tasks, but waiting for the resource that the first task will create to be available to the second task to use it, and so forth? example (conceptual): npm run task1 & waitfor task1 then task2 & waitFor task3 then task4 ... any ideas? EDIT As an example: Lets say that my first task is starting a webserver, and my second task is consuming data from that web-server every time an event happens. Another example: My first task could be starting webdriver

Pass command line — argument to child script in Yarn

跟風遠走 提交于 2019-12-08 19:04:10
问题 I have a package.json that looks similar to this: "scripts": { "dev": "cross-env BABEL_ENV=client webpack --config webpack/client.development.js && yarn dev:stub-server | cross-env BABEL_ENV=server babel-node src/server/server.js", "dev:stub-server": "./node_modules/.bin/robohydra ./stubs/robohydra-config.json -p 3100" } I added some logic in the code to change the way the dev:stub-server is configured depending on a command line argument. So, whenever I run the following I get what I expect:

Cross-platform pipe command in NPM script

ⅰ亾dé卋堺 提交于 2019-12-08 02:24:14
问题 Considering we have NPM script with a pipe, similarly to what's suggested in Istanbul documentation: "coveralls": "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls" It obviously doesn't take Windows into account. How can such command with a pipe be made cross-platform in Node.js package? The question is specific to Coveralls but isn't limited to it; this could be any command with a pipe. 回答1: Both Bash and the Windows command line (e.g. cmd.exe and PowerShell ) have the pipe

npm v6.4.1 not running `prepare` inside docker

♀尐吖头ヾ 提交于 2019-12-08 02:18:29
问题 I am trying to install a package inside of a docker container but the prepare script is not being run. Here is a Dockerfile which replicates the issue: FROM ubuntu:18.04 # Replace shell with bash so we can source files to use npm RUN rm /bin/sh && ln -s /bin/bash /bin/sh RUN apt-get update && apt-get upgrade -y RUN apt-get install wget git -y RUN wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash RUN source ~/.nvm/nvm.sh; nvm install v10.12.0; nvm use v10.12

How to push to github with custom commit message with npm scripts?

若如初见. 提交于 2019-12-07 05:23:31
问题 In my package.json I have this "scripts": { "start": "gulp serve", "git": "git add . && git commit -m 'some-message' && git push --all" }, In the terminal I run npm run git and the changes are pushed. But how can I change the commit message on the fly? For example npm run git MESSAGE='another commit' 回答1: A solution involving some npm trickery might consist of: "scripts": { "git": "git add . && git commit -m", "postgit": "git push --all" }, To be called like: npm run git -- "Message of the

Cross-platform pipe command in NPM script

自闭症网瘾萝莉.ら 提交于 2019-12-06 10:55:02
Considering we have NPM script with a pipe, similarly to what's suggested in Istanbul documentation : "coveralls": "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls" It obviously doesn't take Windows into account. How can such command with a pipe be made cross-platform in Node.js package? The question is specific to Coveralls but isn't limited to it; this could be any command with a pipe. Both Bash and the Windows command line (e.g. cmd.exe and PowerShell ) have the pipe operator ( | ) so that shouldn't be a concern regarding cross-platform compatibility. Given your example

In Expo, Requiring module “fetch”, threw an exception: ReferenceError: Can't find variable: self

大城市里の小女人 提交于 2019-12-06 02:08:39
I have searched across different possible answers, but didn't find any appropriate addressing this specific error. I have mentioned the exact error string in the question title. This error started appearing when I installed fetch npm module in my ReactNative app. This error appears just at the time app is launched/loaded on my phone during development. Before installing fetch , my app was loading correctly on the phone. In windows CLI there is no such error that assist me to resolve the issue, it just shows the build is successful. I am using Expo for my ReactNative app development. Please