npm-scripts

Pass argument from script to gulp task

耗尽温柔 提交于 2019-12-20 04:37:22
问题 I have package.json scripts with the following structure: "scripts": { "watch:build": "tsc --watch", "watch:server": "nodemon ./src/app.js --watch 'app'", "build": "tsc && gulp do_something", "start": "npm-run-all clean build --parallel watch:build", "watch:server --print-label" } I would like to start the application as npm run start with_argument and pass it to build script, to perform actions in the gulp task based on that argument. I read a lot of tutorial and how to articles, but without

How to set env var for .npmrc use

血红的双手。 提交于 2019-12-18 04:16:47
问题 I need a module in my project to download a private npm package. To accomplish this, I am using a .npmrc file to supply a read-only token needed to download the package. To keep the token supplied by npm out of the file, I wish to add it as an environment variable and let it expand in the file. E.g: # .npmrc //registry.npmjs.org/:_authToken=${NPM_TOKEN} I can't figure out how to get that NPM_TOKEN added to the env before it is referenced for the install. I tried using an npm preinstall script

How to set env var for .npmrc use

[亡魂溺海] 提交于 2019-12-18 04:16:06
问题 I need a module in my project to download a private npm package. To accomplish this, I am using a .npmrc file to supply a read-only token needed to download the package. To keep the token supplied by npm out of the file, I wish to add it as an environment variable and let it expand in the file. E.g: # .npmrc //registry.npmjs.org/:_authToken=${NPM_TOKEN} I can't figure out how to get that NPM_TOKEN added to the env before it is referenced for the install. I tried using an npm preinstall script

npm ERR! missing script build

一世执手 提交于 2019-12-13 05:36:12
问题 I'm using Windows 10 and powershell, trying to run a webpack app cloned from my github. When I type npm run start I get: npm ERR! missing script: build; The build script is most definitely in my package.json: "scripts": { "build": "webpack --mode development", "start": "npm run build; webpack-dev-server --open", "lint": "eslint src/*.js", "test": "karma start karma.conf.js" }, When I'm on a mac, npm run start opens a local dev server just fine. Any ideas why I am unable to run this on my pc?

Use cpx and typescript to watch and serve file changes

 ̄綄美尐妖づ 提交于 2019-12-11 14:38:05
问题 I am using cpx to copy .yml files and typescript to compile .ts files. All of this is then served with an npm script using node as follows: start: "tsc && cpx \"src/**/*.yml\" dist/src && node ./dist/server.js This functions without a problem on the production server. The problem arises when I try to run the setup in watch mode during development using tsc-watch as follows: "start:watch": "cpx \"src/**/*.yml\" dist/src --watch && tsc-watch --onSuccess \"node ./dist/server.js\" --onFailure \

Does a global install of a local node project just create executable links back to the project?

只谈情不闲聊 提交于 2019-12-11 14:18:51
问题 I'm doing some work on a command line interface, and to test it from the root of the project I do: npm i -g After this I can test the command on various projects. IIUC running npm i -g creates global links that are executable, but the actual files being run are the original project files? Running: ole@mki:~/SuperflyCSS/cli$ npm list -g | grep superfly ├─┬ @superflycss/cli@4.1.2 -> /home/ole/SuperflyCSS/cli │ ├─┬ @superflycss/pli@3.0.0 Seems to indicate that this is the case. I just want to

How to rename file with npm script

耗尽温柔 提交于 2019-12-11 07:05:34
问题 I am using copyfiles as an npm scirpt copyfiles -u 2 /src/app/conf.dev.json dist/config/ but in the end I want to get the file renamed How would you rename the input file in to something like conf.json ? I check the docs and didn't find that it is possible to achieve with copyfiles . Any thoughts? UPDATE : I follow up to this Rename file with NPM but getting an error when do npm run copy : "copy": "copyfiles -u 2 /src/app/conf.dev.json dist/config/ && node -e require('fs').rename('dist/config

How to change the default configuration files used in bootstrapping of reactJs through npm

ε祈祈猫儿з 提交于 2019-12-11 02:22:41
问题 I've created a very basic hello world reactJs application using create-react-app command which is part of npm. Here is the directory structure which I get as part of the application template: My package.json file looks like this: { "name": "hello-world", "version": "0.1.0", "private": true, "dependencies": { "react": "^15.4.2", "react-dom": "^15.4.2" }, "devDependencies": { "react-scripts": "0.9.5" }, "scripts": { "start": "react-scripts start", "build": "react-scripts build", "test": "react

How do I run concurrent scripts when webpack watch fires?

为君一笑 提交于 2019-12-11 02:17:04
问题 Background I currently have an npm script that looks something like "dev":"yarn install && concurrently -k \"npm run webpack\" \"cd dist/ && node App.js\" \"npm run test\" \"npm run lint\"" Logically this runs webpack, starts the app, lints, and tests in parallel. npm webpack in that script has --watch set Note: this is for dev. The Problems This tries to run the app before it has webpacked This won't re-run the app when webpack repacks due to watch The Goal Run npm run webpack once When it

Why Can't I Set Env Variables By Running A BASH Script From An Npm Script?

[亡魂溺海] 提交于 2019-12-10 22:40:56
问题 I have a nodejs javascript project, but I would like to set a bunch of environment variables locally. created a bash file that just exports some variables: #!/usr/bin/env bash export waka=flaka export fat=booty When I use the dot to source and run the file from the command line it works fine: . ./env.sh And I can see the variable has been set echo $waka # prints "flaka" But then I try to take this command and make it an npm script by adding it to my package.json scripts: { "set-env": ". ./env