package.json

Install npm package without dependencies

喜欢而已 提交于 2019-11-30 19:27:29
问题 I am looking for best solution how to install npm package without it's dependencies described in it's package.json file. The goal is to change dependencies versions before install package. I can do it manually for one package by downloading source, but if you have many nested dependencies it becomes a problem. 回答1: Here's a shell script that seems to get you the extracted files you need. #!/bin/bash package="$1" version=$(npm show ${package} version) archive="${package}-${version}.tgz" curl -

Import from subfolder of npm package

淺唱寂寞╮ 提交于 2019-11-30 09:04:05
I've been working on creating a small library of React components for use in several other projects. I am publishing the package internally (using a private GitHub repository) and then including in another project. However, when I go to import from a subdirectory of the package I am not able to do so as the paths don't match. The projects using the package all utilize webpack to bundle/transpile code as I am trying to avoid doing any building in the component library if possible. Directory Structure - package.json - src/ - index.js - Button/ - index.js - Button.jsx - ButtonGroup.jsx - Header/

How to update all Node.js modules automatically?

别说谁变了你拦得住时间么 提交于 2019-11-30 04:05:57
During my work with the Node.js environment, I faced the issue of version maintenance of Node.js modules. I would like to be sure that all internal Node.js modules are updated. Many of existing manuals focus just on how to update Node.js modules, but not how to automate such routine. The question: How to update all Node.js modules automatically to the latest version? Ideally, it should be some script, job, or task. To update all Node.js modules manually: Open console with administrative permissions Go to Node.js installation folder: cd C:\Program Files\nodejs Update npm: npm i npm@latest Go to

OS independent access to variables in package.json

不打扰是莪最后的温柔 提交于 2019-11-30 03:03:47
To access a variable in npm scripts you would do something like this in your package.json : "scripts": { "preinstall": "echo ${npm_package_name}" } The problem is that works only in Unix, not Windows, where you have to use %npm_package_name% . Is there a way to do this OS independent? It will be good if npm could do such a variable expansion, before invoking the command. To make it cross-platform, use cross-var : "scripts": { "preinstall": "cross-var echo ${npm_package_name}" } There's no known way to do this that's OS independent. A good workaround is to execute the command within a node

Create WebStorm run configurations from package.json “scripts” section

风格不统一 提交于 2019-11-29 22:33:23
In my package.json file, I have the following "scripts" configuration. ... "scripts": { "start": "watchify -o lib/index.js -v -d .", "build": "browserify . | uglifyjs -cm > lib/index.js", "test": "jest" } ... This allows me to run npm start , npm build and npm test from the command line. This is great! But ideally, I would like to be able to run those tasks from within WebStorm using run configurations, due to how convenient the interface is. I have not been able to figure out how to do this. Is there a way to create my own custom run configurations or automatically generate them from my

What are the main uses for the NPM package.json file?

一世执手 提交于 2019-11-29 18:44:58
问题 I read from here that the dependencies in the package.json file allow people to install the dependencies if they install your project through npm- Finally, the dependencies field is used to list all the dependencies of your project that are available on npm. When someone installs your project through npm, all the dependencies listed will be installed as well. Additionally, if someone runs npm install in the root directory of your project, it will install all the dependencies to ./node_modules

Npm peer dependency error

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-29 13:27:54
I am getting the npm peer dependency error repeatedly with npm install command . This is my package.json on which i have unmet peer dependency on react and webpack npm WARN react-datepicker@0.25.0 requires a peer of react@^0.14.0 but none was installed. npm WARN babel-loader@6.2.4 requires a peer of webpack@1 || ^2.1.0-beta but none was installed. npm WARN desktop-react@1.0.0 No repository field. npm WARN desktop-react@1.0.0 license should be a valid SPDX license expression { "name": "xxxxxxxxx", "version": "x.x.x", "description": "", "main": "index.js", "author": "", "license": "xxxxxxx",

Whats the difference when configuring webpack babel-loader vs configuring it within package.json?

馋奶兔 提交于 2019-11-29 10:54:46
Hi please help me understand the differences between setting babel config inside .babelrc vs webpack loader options, vs inserting it in package.json. For example, Would it make any difference if I put the presets in the webpack babel-loader options vs package.json or a separate .babelrc config file? In webpack config: { test: /\.(js|jsx|mjs)$/, loader: require.resolve('babel-loader'), options: { "presets": [ "react-app" ] }, }, In package json: "babel": { "presets": [ "react-app" ] }, Webpack config : config the babel-loader completely in webpack.conf.js (no .babelrc). Webpack config +

How to set env var for .npmrc use

丶灬走出姿态 提交于 2019-11-29 07:21:27
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: "preinstall": "NPM_READ_ONLY_TOKEN=my_token_goes_here_foo_bar" ** But I still get the same error:

How to specify the path of `package.json` to npm?

▼魔方 西西 提交于 2019-11-28 22:18:17
I use npm scripts to build my project. I'd like to be able to run the scripts from a different directory. That is, instead of doing the following: cd project; npm run build; cd .. ...I'd like to simply do something like: npm run build -config project/package.json; or npm run build -wd project; Is this possible? This worked for me: npm --prefix /path/to/project run build Where path/to/project is the directory where your package.json with "build" command defined. 来源: https://stackoverflow.com/questions/37078968/how-to-specify-the-path-of-package-json-to-npm