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

Let’s say you’re developing a package “A” that have @types/some-module package in devDependencies. For some reason you’re exporting the type from @types/some-module: import { SomeType } from ‘some-module’; export default class APackageClass { constructor(private config: SomeType) { // … } } Right now TypeScript consumers of package “A” are unable to guess what SomeType is, … Read more

SyntaxError: Cannot use import statement outside a module

Verify that you have the latest version of Node.js installed (or, at least 13.2.0+). Then do one of the following, as described in the documentation: Option 1 In the nearest parent package.json file, add the top-level “type” field with a value of “module”. This will ensure that all .js and .mjs files are interpreted as … Read more

Is there a way to get version from package.json in nodejs code?

I found that the following code fragment worked best for me. Since it uses require to load the package.json, it works regardless of the current working directory. var pjson = require(‘./package.json’); console.log(pjson.version); A warning, courtesy of @Pathogen: Doing this with Browserify has security implications. Be careful not to expose your package.json to the client, as … Read more

What’s the difference between dependencies, devDependencies and peerDependencies in npm package.json file?

Summary of important behavior differences: dependencies are installed on both: npm install from a directory that contains package.json npm install $package on any other directory devDependencies are: also installed on npm install on a directory that contains package.json, unless you pass the –production flag (go upvote Gayan Charith’s answer), or if the NODE_ENV=production environment variable … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)