package.json

OS independent access to variables in package.json

荒凉一梦 提交于 2019-11-28 21:03:05
问题 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. 回答1: To make it cross-platform, use cross-var: "scripts": { "preinstall": "cross-var echo ${npm_package_name}" } 回答2: There

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

守給你的承諾、 提交于 2019-11-28 19:14:54
问题 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.

How do I decide whether @types/* goes into `dependencies` or `devDependencies`?

可紊 提交于 2019-11-28 16:16:45
I use TypeScript 2 in my project. I'd like to use some js library, but also typings for that library. I can install types with simple npm install @types/some-library . I'm not sure if I should --save or --save-dev them. It seems to me that even DefinetelyTyped GitHub readme kind of mentions both versions, but never explains them. I would think that @types should be in devDependencies , as types are needed for development and aren't used in runtime, but I saw many times @types in just dependencies . I'm confused. How should I decide whether @types/* goes into dependencies or devDependencies ?

How to display the app version in Angular?

孤街浪徒 提交于 2019-11-28 15:26:56
How do I display the app version in angular application? the version should be taken from package.json file { "name": "angular-app", "version": "0.0.1", ... } In angular 1.x, I have this html: <p><%=version %></p> In angular, this is not rendered as version number, but instead just printed as it is ( <%=version %> instead of 0.0.1 ). If you want to use/show the version number in your angular app please do the following: Prerequisites: Angular file and folder structure created via Angular CLI TypeScript 2.9 or later! (Supported from Angular 6.1 upwards) Steps: In your /tsconfig.app.json enable

“style” field in package.json

南楼画角 提交于 2019-11-28 10:52:06
I noticed that Bootstrap and Normalize.css both have a "style" field in their package.json. Why do they have this? If I had to guess, it's to allow users to import the defined stylesheet as easily as doing require('bootstrap') , but that doesn't seem to be the case. From Techwraith's pull request that added it to Bootstrap: Many modules in npm are starting to expose their css entry files in their package.json files. This allows tools like npm-css , rework-npm , and npm-less to import bootstrap from the node_modules directory. [...] It's actually not written anywhere but in the code for these

Error: EPERM: operation not permitted, unlink 'D:\\Sources\\**\\node_modules\\fsevents\\node_modules\\abbrev\\package.json'

佐手、 提交于 2019-11-28 08:54:41
I just updated npm to 5.4.0 . Now, Whenever I want install a npm package I get the following error: D:\Sources\DownloadCms\Md.Download\Web.Angular>npm install mds.angular.datetimepicker@latest --save npm ERR! path D:\Sources\DownloadCms\Md.Download\Web.Angular\node_modules\fsevents\node_modules\abbrev\package.json npm ERR! code EPERM npm ERR! errno -4048 npm ERR! syscall unlink npm ERR! Error: EPERM: operation not permitted, unlink 'D:\Sources\DownloadCms\Md.Download\Web.Angular\node_modules\fsevents\node_modules\abbrev\package.json' npm ERR! at Error (native) npm ERR! { Error: EPERM:

Field 'browser' doesn't contain a valid alias configuration

旧城冷巷雨未停 提交于 2019-11-28 07:06:47
I've started using webpack2 (to be precise, v2.3.2 ) and after re-creating my config I keep running into an issue I can't seem to solve I get (sorry in advance for ugly dump): ERROR in ./src/main.js Module not found: Error: Can't resolve 'components/DoISuportIt' in '[absolute path to my repo]/src' resolve 'components/DoISuportIt' in '[absolute path to my repo]/src' Parsed request is a module using description file: [absolute path to my repo]/package.json (relative path: ./src) Field 'browser' doesn't contain a valid alias configuration aliased with mapping 'components': '[absolute path to my

Do I need both package-lock.json and package.json?

烈酒焚心 提交于 2019-11-28 04:15:55
After updating my NPM to the latest version (from 3.X to 5.2.0) and running npm install on an existing project, I get an auto-created package-lock.json file. I can tell package-lock.json gives me an exact dependency tree as opposed to package.json . From that info alone, it seems like package.json is redundant and not needed anymore. Are both of them necessary for NPM to work? Is it safe or possible to use only the package-lock.json file? The docs on package-lock.json ( doc1 , doc2 ) doesn't mention anything about that. Edit : After some more thinking about it, I came to the conclusion that if

npm glob pattern not matching subdirectories

非 Y 不嫁゛ 提交于 2019-11-27 23:34:09
In my package.json , I have a scripts block that uses **/*Test.js to match files. When run via npm , they do not match sub-directories more than one level. When executed on the command line directly, they work as expected. Can anyone explain what is happening, and provide a workaround or solution? package.json { "name": "immutable-ts", "scripts": { "test": "echo mocha dist/**/*Test.js", } } Execution % npm run test > immutable-ts@0.0.0 test:unit .../immutable-ts > echo mocha dist/**/*Test.js mocha dist/queue/QueueTest.js dist/stack/StackTest.js % echo mocha dist/**/*Test.js mocha dist/queue

How do I decide whether @types/* goes into `dependencies` or `devDependencies`?

ⅰ亾dé卋堺 提交于 2019-11-27 19:51:13
问题 I use TypeScript 2 in my project. I'd like to use some js library, but also typings for that library. I can install types with simple npm install @types/some-library . I'm not sure if I should --save or --save-dev them. It seems to me that even DefinetelyTyped GitHub readme kind of mentions both versions, but never explains them. I would think that @types should be in devDependencies , as types are needed for development and aren't used in runtime, but I saw many times @types in just