Adding Express as a javascript library to WebStorm 6 - express

Can any one show me how to add Express as a javascript library to Web Storm 6. I've installed Expresss via npm. Then in Web Storm preferences I've added a new library called Express and attached the node_modules/express folder.
But Web Storm still complains that it cannot resolve methods like express.bodyParser() etc.
I also don't know what to specify for the Documentation URL for the Express library.
Can anyone help?

I don't know what do you mean by add Express library.If you plan to link global express installation I wouldn't recommend it. My recommendation is to
1 install express globally by using the command line/terminal
npm install -g express
2 Then use the command line to create express application
express myapp
3 Install dependencies
cd myapp && npm install
4 Open myapp directory with Webstorm using File -> Open Directory
If you already have the application check your package.json in your application root directory it should contain express in its dependencies:
{
"name": "hello-world",
"description": "hello world test app",
"version": "0.0.1",
"private": true,
"dependencies": {
"express": "3.x"
}
}
if the express is missing add it in your package json then do npm install

Related

Not finding relative modules on build when linked over "npm link xyz"

When running npm run serve, my VueJS projekt (Vue 2.6.11) running webpack is not finding my locally changed node module.
If i install it normally, it works (of course) and i see the changes i made in it, in the node modules folder of the project that linked it - so the link itself should be fine.
I linked it by using "npm link" in the project i want to link (i ran the build before) and then using "npm link [name]" in my main project.
The import i'm using in the main.js looks like this:
import [module-name] from '[module-name]'
just as it did when i had it installed regularly.
I also changed the settings of webpack by doing this:
module.exports = {
configureWebpack: {
resolve: {
symlinks: false //npm link
},
...
because the documentation of vue stated (for version 2, the new version has information about chainWebpack in it), that links won't work otherwhise as they're not resolved without it. still, this is the output on npm run serve:
This dependency was not found:
* [module-name] in ./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/views/CommentWriteArea.vue?vue&type=script&lang=js&
To install it, you can run: npm install --save [module-name]
(with the correct name in it of course)
Other solutions like installing the local version or forking the repository are not an option. It has to be linked for my use case

how can I create app with dynamic name using npm

I'm using Jenkins pipeline to compile npm app.
I want to use a parameter for my npm app, see each branch will publish the app under different name.
Also, I need some "default value, for the developers when they are working in their local env
for example, my package.json:
{
"name": ${some_env_var} : default_value",
"version: 1.0.0
...
}
does it possible?

Snowpack with local npm packages

We have problem to run snowpack with our package structure.
Our structure:
adapters
app
core
presentation
Each package contains typescript and all are used in the app package.
"dependencies": {
"#project/adapters": "file:../../adapters",
"#project/core": "file:../../core",
"#project/presentation": "file:../../presentation",
}
I get the error Dependency Install Error: Package "#project/adapters/src/repositories/GradeFeedRepositoryImpl" not found. Have you installed it?
How do I need to configure snowpack, web pack, babel, ... to run this?
I have had success with packing modules (using: npm pack /path/to/module from the root of the module's folder) and adding the tarball to my package.json from a folder within the repo. e.g.,
"dependencies": {
...
"adapters": "file:packs/adapters-1.0.0.tgz"
...
}
Another option, see if making this edit to your snowpack.config.js file helps:
packageOptions: {
external: [
"#projects/adapters"
]
}

Vuepress run built project

I built a simple vuepress project with pwa support. Vuepress so far does only provide two scripts:
"scripts": {
"docs:dev": "vuepress dev docs",
"docs:build": "vuepress build docs"
}
The dev scripts works fine and I can check my web app locally, but I would like to check the app which my build script provides. The documentation of vuepress does not provide this information.
How can I run the build script and run afterwards the built app locally (in my case to check the pwa)
Once built, the output is located in <your-vuepress-project>/src/.vuepress/dist. To serve it, install http-server (npm install http-server) and then run http-server ./src/vuepress/dist from your project folder.
Note that this requires you to have installed node.js

Browserify not accessing node_modules

I made a visual recognition app using Watson api which included a node_modules file necessary to run the api call (the api call was made from api_request and it required modules in my node_modules folder. After it worked in the terminal, I installed and use browserify to build a file in my package.json like so:
"build": "browserify api_request.js -o bundle.js"
However bundle.js gave an error when a module in the node_modules folder required another module in the node_modules folder. It doesn't seem like browserify is using 'node_modules' directory when using symlink. Does anyone know how to fix this?
Starting from (v2.0.0) you can use browserify to run the watson-developer-cloud npm module client side. You can also require individual services now.
For example, to use Tone Analyzer client side you will need a js file (e.g app.js):
var ToneAnalyzerV3 = require('watson-developer-cloud/tone-analyzer/v3');
var toneAnalyzer = new ToneAnalyzerV3({/* credentials */});
toneAnalyzer.tone({ text: 'Greetings from Watson Developer Cloud!' },
function(err, tone) {
if (err)
console.log(err);
else
console.log(JSON.stringify(tone, null, 2));
});
Use browserify to compile the client side js:
browserify app.js -o bundle.js"
You need to have browserify installed:
npm install browserify -g
There is a migration guide if you want to move from v1.X to v2.X