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
I've tried many different docs and tutorials to publish a scoped npm package on a private gitlab instance.
So far I've:
Created a deploy token with package write & read permissions:
Setup a .npmrc file with the following contents:
#<scope>:registry=https://<domain>/api/v4/packages/npm/
//<domain>/api/v4/projects/<id>/packages/npm/:_authToken=<token>
//<domain>/api/v4/packages/npm/:_authToken=<token>
Added "publishConfig" to "package.json":
{
"name": "#<scope>/<name>",
"version": "1.0.0",
"main": "dist/index.js",
"license": "MIT",
"publishConfig": {
"#<scope>:registry": "https://<domain>/api/v4/projects/<id>/packages/npm"
},
"scripts": {
"build": "tsc",
"prepublish": "tsc"
},
"devDependencies": {
"ts-node": "^9.1.1"
}
}
Verified that the repo allows packages to be stored:
But everytime I try and run either npm publish or yarn publish, it builds, packages but fails to publish:
The log file verbosily repeats the error log above.
I'm trying to release a private SDK for an internal service and would need a way to publish it so only those with the correct credentials can install it on their projects.
The link provided (Not Found - PUT https:// <link...> ) redirects to npmjs.com, which I believe wasn't supposed to happen, since I'm trying to store it on Gitlab instead of purchasing an organization on npmjs.
I've tried this process both on the private domain (running gitlab 13.9.1) and on https://gitlab.com, both with the same result on the same repository configuration disclosed above.
Am I missing some step? Thanks in advance!
Your .npmrc file has both instance and project level endpoints, but if you're using a project deploy token, the authentication of the token you're providing is scoped to the project, so you should only have the project endpoint.
#<scope>:registry=https://<domain>/api/v4/projects/<ID>/packages/npm/
//<domain>/api/v4/projects/<ID>/packages/npm/:_authToken=<TOKEN>
The project ID in the redacted part of URL shown as part of error message resulting from attempted publish looks rather long. The project's ID isn't the project's slug. it's a numeric value instead.
I am trying to execute tests via a Heroku pipeline with the following app.json:
{
"environments": {
"test": {
"addons": [
{
"plan": "mongolab:sandbox"
}
],
"scripts": {
"test": "yarn test && ((nohup yarn test:start:api &) && sleep 10 && yarn test:integration)"
}
}
}
}
Locally on my Linux machine the command works but on Heroku I can not reach the API service:
-----> Running test command `yarn test && ((nohup yarn test:start:api &) && sleep 10 && yarn test:integration)`...
yarn run v1.6.0
warning package.json: No license field
$ mocha-webpack --webpack-config ./webpack.config.js --require test/setup.js model/**/*.spec.js api/**/*.spec.js
WEBPACK Compiling...
WEBPACK Compiled successfully in 792ms
MOCHA Testing...
0 passing (1ms)
MOCHA Tests completed successfully
Done in 4.12s.
yarn run v1.6.0
warning package.json: No license field
$ babel-node ./server.js --presets es2015,stage-2
yarn run v1.6.0
warning package.json: No license field
$ mocha-webpack --webpack-config ./webpack.config.js --require test/setup.js model/**/*.integration.js api/**/*.integration.js
WEBPACK Compiling...
WEBPACK Compiled successfully in 1092ms
MOCHA Testing...
User
Db.prototype.authenticate method will no longer be available in the next major release 3.x as MongoDB 3.6 will only allow auth against users in the admin db and will no longer allow multiple credentials on a socket. Please authenticate using MongoClient.connect with auth credentials.
(node:570) DeprecationWarning: `open()` is deprecated in mongoose >= 4.11.0, use `openUri()` instead, or set the `useMongoClient` option if using `connect()` or `createConnection()`. See http://mongoosejs.com/docs/connections.html#use-mongo-client
Db.prototype.authenticate method will no longer be available in the next major release 3.x as MongoDB 3.6 will only allow auth against users in the admin db and will no longer allow multiple credentials on a socket. Please authenticate using MongoClient.connect with auth credentials.
Successfully initialized mongoose-seed
Users collection cleared
Successfully created document [0] of User model
Error: Error: connect ECONNREFUSED 127.0.0.1:8080
...
How can I determine the URI to connect to the API-service itself (nohup yarn test:start:api &)?
The API is built with express-restify-mongoose and as it seems there is no out of the box testing like inject with hapijs (https://hapijs.com/api#-await-serverinjectoptions)
How can I make my tests run on Heroku?
Your tests are trying to connect to 127.0.0.1:8080, but your web application is almost certainly running elsewhere. Heroku provides the PORT environment variable telling your back-end code what port it should use.
Try updating your tests to connect to whatever that variable holds instead of 8080.
We have an Angular + Ionic + Cordova project with multiple devs that we'd like to manage cordova plugin dependencies for. We are using Cordova CLI 5+, and when manually running the install commands (e.g. cordova plugin add cordova-plugin-camera), a new line gets added to the cordovaPlugins section of the package.json file. Here's what the finished product looks like:
"cordovaPlugins": [
"cordova-plugin-camera",
"cordova-plugin-console",
"cordova-plugin-contacts",
"cordova-plugin-device",
"cordova-plugin-dialogs",
"cordova-plugin-file",
"cordova-plugin-geolocation",
"cordova-plugin-media",
"cordova-plugin-media-capture",
"cordova-plugin-network-information",
"cordova-plugin-splashscreen",
"cordova-plugin-statusbar",
"cordova-plugin-vibration",
"com.ionic.keyboard"
]
That's all great, except we can't find any way for dev #2 to npm install those plugins - instead, he has to run the commands individually, which then adds a duplicate line to package.json, dirtying the repository. We are sure there must be a command to install these, but can't find it. Can anyone shed some light?
What Caused Our Issue
We had originally used this Ionic + Cordova + Grunt seed project to spawn our initial app. The project includes a number of Cordova hooks that, among other things, add and remove platforms and plugins from the relevant cordovaPlatforms and cordovaPlugins sections in package.json when you run the corresponding command (i.e. cordova plugin add cordova-plugin-media adds a line to cordovaPlugins).
To better support local testing (trying new versions of a plugin, for example), and to prevent cross-dev dependency issues, we disabled the seed project hook and now hand-craft the package.json as needed.
Properly Managing Cordova Plugins
In turns out, the Ionic CLI uses package.json to manage Cordova app state in terms of platforms and plugins (as of version 1.3.19, it appears).
Populating package.json with two sections, cordovaPlatforms and cordovaPlugins has allowed us to do a simple ionic state restore to get the Cordova environment in shape for emulation, building, etc.
Specifying Versions
To further lock-down our app's state and development environment, we've also specified the target version of the Cordova platforms and plugins that we are using by adding the version number. Here's what we use:
{
...
"cordovaPlatforms": [
"android#4.0.2",
"ios#3.8.0"
],
"cordovaPlugins": [
"cordova-plugin-camera#1.1.0",
"cordova-plugin-contacts#1.1.0",
"cordova-plugin-device#1.0.1",
"cordova-plugin-file#2.1.0",
"cordova-plugin-media#1.0.1",
"cordova-plugin-media-capture#1.0.1",
"cordova-plugin-network-information#1.0.1",
"cordova-plugin-splashscreen#2.1.0",
"cordova-plugin-statusbar#1.0.1",
"cordova-plugin-vibration#1.2.0",
"com.ionic.keyboard#1.0.5"
]
}
tl;dr
Once you have the above in your package.json, you can then ensure that your local environment is in the proper state via ionic state restore (v1.3.19+) which will chew through package.json and install platforms and plugins as needed.
You can add a postinstall command. Look below
{
"cordovaPlugins": [
"com.ionic.keyboard#1.0.4",
],
"cordovaPlatforms": [
"android#4.1.1",
],
"scripts": {
"postinstall": "ionic state restore",
"clean": "ionic platform remove android; ionic platform remove ios; ionic platform remove browser; git checkout package.json"
}
}
Bonus : use npm run clean followed by npm install if you wish to start clean i.e reinstall all platforms
may be it's a bit late into the game, but this is my postinstall script
"postinstall": "bower i && gulp && ionic state reset && ionic config build"
it installs the bower dependencies, e.g. ionic lib
it restores Cordova plugins
it re-builds the configuration you did via ionic config command
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