npm-scripts

npm package.json OS specific script

会有一股神秘感。 提交于 2020-01-22 13:19:27
问题 I would like to create a package.json build script that executes slightly different set of commands when run from Windows, Linux, Mac. The problem is that I cannot find a way to put it in package.json file that will run without problems at every system. Here is an example that I would like to have: "scripts" : { "build.windows" : "echo do windows specific stuff", "build.linux" : "echo do linux specific stuff", "build.mac" : "echo do mac specific stuff", "build" : "??????????????" <- what to

Problem running parallelshell Nodejs script

家住魔仙堡 提交于 2020-01-13 19:33:28
问题 In my package.json file I have the following scripts: "scripts": { "start": "npm run watch:all", "test": "echo \"Error: no test specified\" && exit 1", "lite": "lite-server", "sass": "node-sass -o sass/ css/", "watch:sass": "onchange 'sass/*.scss' -- npm run sass", "watch:all": "parallelshell 'npm run watch:sass' 'npm run lite'" } Whenever I run my code I got this error message: crs@1.0.0 start /home/hazem/crs > npm run watch:all > crs@1.0.0 watch:all /home/hazem/crs > parallelshell 'npm run

Apply visual styling to echo commands used in npm scripts via package.json

久未见 提交于 2020-01-13 05:57:11
问题 Have recently put together a build tool with npm and package.json scripts, and I have a few echo commands to state which parts of the pipeline are currently running. For example (from my package.json ): { "scripts": { "clean": "rimraf a-directory/", "preclean": "echo \"\n[ Cleaning build directories ]\n\"" } } When I Bash: npm run clean it prints my echo message, and then cleans the appropriate directory. I'd like to change colour, font weight, background text colour to make these echo

Apply visual styling to echo commands used in npm scripts via package.json

佐手、 提交于 2020-01-13 05:57:09
问题 Have recently put together a build tool with npm and package.json scripts, and I have a few echo commands to state which parts of the pipeline are currently running. For example (from my package.json ): { "scripts": { "clean": "rimraf a-directory/", "preclean": "echo \"\n[ Cleaning build directories ]\n\"" } } When I Bash: npm run clean it prints my echo message, and then cleans the appropriate directory. I'd like to change colour, font weight, background text colour to make these echo

sending custom arguments to npm (yarn) scripts with lerna

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-04 07:51:11
问题 I have an issue when trying to pass arguments to an npm script with lerna . I have a node script that I want to run inside each package in the workspace. lerna docs suggests the following: { "scripts": { "my-script": "lerna exec -- node \\$LERNA_ROOT_PATH/scripts/my-script.js" } } so now, if I run in the root yarn run my-script it will run the script inside each package in the workspace. Sometimes, I need to scope the execution to a specific package. So running this from command line

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

眉间皱痕 提交于 2020-01-02 08:07:42
问题 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

Stop all processes depending on npm start…

99封情书 提交于 2019-12-31 03:30:39
问题 I am starting multiple npm tasks in parallel (using & , not just in sequence && ). Thus in package.json : "start": "npm run watch-blog & npm run watch-data & npm run server", And those sub-tasks are useful stuff to me like: "watch-blog" : "watchy -w _posts/**/* -- touch _pages/blog.md", Question: How can I all shut down all three tasks together? I noticed CTRL – C is only killing the last. (my watch-blog survives and keeps „touching“) Closing the terminal window doesn't help. Only killall

Nodejs npm scripts fail with “SyntaxError: Unexpected token {”

雨燕双飞 提交于 2019-12-23 12:35:15
问题 I've just imported my Reactjs project to a new machine on Ubuntu and installed most dependencies with npm install successfully bar the following: npm WARN optional Skipping failed optional dependency /react-scripts/fsevents: npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.0.17 npm WARN optional Skipping failed optional dependency /chokidar/fsevents: npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.1.2 Trying to run the

babel polyfill being included, but forEach still doesn't work in IE11 on NodeLists

前提是你 提交于 2019-12-20 20:38:36
问题 I've got Webpack working with Babel and including the @babel/polyfill, yet IE11 is still throwing a SCRIPT438 error when trying to use .forEach on a NodeList . Here's my package.json { ... "scripts": { "build:js": "webpack --config ./_build/webpack.config.js" }, ... "browserslist": [ "IE 11", "last 3 versions", "not IE < 11" ], "babel": { "presets": [ [ "@babel/preset-env", { "useBuiltIns": "usage" } ] ] }, "devDependencies": { "@babel/core": "^7.1.6", "@babel/preset-env": "^7.1.6", "babel

How can I reference package version in npm script?

允我心安 提交于 2019-12-20 09:22:07
问题 I want to reference my package version in a npm script so I can show current version in the app. Something like { "name": "bla", "version": "1.0.0", "author": "bla bla", "scripts": { "build": "node VERSION=<<package.version>> build/build.js" } } Is there a way to do this? 回答1: 1) Referencing package version in npm-scripts. In npm-script 's you can reference the version using the variable npm_package_version . For example: Using a bash shell (E.g. Linux, macOS): { ... "version": "1.0.0",