I start recently my first nodeJs application on IBM blumix, in following these tutorial http://ibm-bluemix.coderpower.com/#/warmup/55e07bf49924f792327901cd/code.
i following the instruction but when I start my application I have the error Cannot find module 'ibmbluemix'
I have the same code as the tutorial, I almost feel that the ibm bluemix module is not installed ... on the cloud ibm bluemix.
Here is the code
package.json
{
"name": "NodejsStarterApp",
"version": "0.0.1",
"description": "A sample nodejs app for Bluemix",
"scripts": {
"start": "node app.js"
},
"dependencies": {
"express": "4.12.x",
"cfenv": "1.0.x"
},
"repository": {},
"engines": {
"node": "0.12.x"
}
}
app.js
var express = require('express');
var ibmbluemix = require('ibmbluemix');
var config = {
applicationId:"FirstAppli",
applicationRoute:"firstappli.mybluemix.net"
};
// cfenv provides access to your Cloud Foundry environment
// for more info, see: https://www.npmjs.com/package/cfenv
var cfenv = require('cfenv');
// create a new express server
var app = express();
// serve the files out of ./public as our main files
app.use(express.static(__dirname + '/public'));
var router = express.Router();
router.get('/', /* #callback */ function(req,res){
ibmbluemix.initialize(config).then(/* #callback */ function(success) {
res.json({ message : 'sdk initialised' });
},
/* #callback */ function(err){
res.json({ message : 'sdk error' });
});
});
app.use('/api', router);
// get the app environment from Cloud Foundry
var appEnv = cfenv.getAppEnv();
// start server on the specified port and binding host
app.listen(appEnv.port, '0.0.0.0', function() {
// print a message when the server starts listening
console.log("server starting on " + appEnv.url);
});
the log on starting
Starting app instance (index 0) with guid 8a0df22f-7c18-476f-8dc0-91c3db946ac6
Updated app with guid 8a0df22f-7c18-476f-8dc0-91c3db946ac6 ({"state"=>"STARTED"})
Detected 1024 MB available memory, 512 MB limit per process (WEB_MEMORY)
Recommending WEB_CONCURRENCY=2
Activating app management utilities: devconsole, shell, inspector
2015/10/27 10:46:52 authenticator url is detected as https://api.ng.bluemix.net/v2/apps/8a0df22f-7c18-476f-8dc0-91c3db946ac6/env
2015/10/27 10:46:52 The application base path is detected as /home/vcap
2015/10/27 10:46:52 Starting the proxy agent on port 61392
2015/10/27 10:46:52 Begin to start the runtime...
Starting utility: devconsole...
Adding proxy entry with: {"type": "http-forward", "backend": "127.0.0.1:8788", "host": "*", "uri_prefix": "bluemix-debug/manage"}
2015/10/27 10:46:52 Catch event "/home/vcap/app/.app-management/bin/proxy.config": WRITE. Reload the registry.
Starting utility: shell...
Adding proxy entry with: {"type": "http-forward", "backend": "127.0.0.1:8789", "host": "*", "uri_prefix": "bluemix-debug/shell"}
2015/10/27 10:46:52 Catch event "/home/vcap/app/.app-management/bin/proxy.config": WRITE. Reload the registry.
Starting utility: inspector...
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.0 1132 828 ? S<s 10:46 0:00 wshd: 192t1kppgo2
vcap 29 0.0 0.0 270040 5408 ? S<sl 10:46 0:00 .app-management/bin/proxyAgent
vcap 35 0.0 0.0 19592 3452 ? S< 10:46 0:00 bash /home/vcap/app/.app-management/handlers/start-inspector/run
vcap 45 0.0 0.0 19596 3408 ? S< 10:46 0:00 bash /home/vcap/app/.app-management/scripts/start 61393
vcap 72 0.0 0.0 677992 25228 ? R<l 10:46 0:00 /home/vcap/app/.app-management/node/bin/node bin/dev.js bluemix-debug/manage 8788
vcap 88 0.0 0.0 677992 23480 ? R<l 10:46 0:00 npm
vcap 113 0.0 0.0 611432 20688 ? R<l 10:46 0:00 /home/vcap/app/.app-management/node/bin/node server.js bluemix-debug/shell 8789
vcap 145 0.0 0.0 19588 292 ? R< 10:46 0:00 bash /home/vcap/app/.app-management/handlers/start-inspector/run
vcap 146 0.0 0.0 17172 2472 ? R< 10:46 0:00 ps aux
Adding proxy entry with: {"type": "http-forward", "backend": "127.0.0.1:8790", "host": "*", "uri_prefix": "bluemix-debug/inspector"}
2015/10/27 10:46:52 Catch event "/home/vcap/app/.app-management/bin/proxy.config": WRITE. Reload the registry.
> NodejsStarterApp#0.0.1 start /home/vcap/app
> node app.js
node-inspector is active. Visit the web page to start debugging.
module.js:338
throw err;
^
Error: Cannot find module 'ibmbluemix'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/home/vcap/app/app.js:11:18)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
npm ERR! Linux 3.19.0-25-generic
npm ERR! argv "/home/vcap/app/vendor/node/bin/node" "/home/vcap/app/vendor/node/bin/npm" "start"
npm ERR! node v0.12.7
npm ERR! npm v2.11.3
npm ERR! code ELIFECYCLE
npm ERR! NodejsStarterApp#0.0.1 start: `node app.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the NodejsStarterApp#0.0.1 start script 'node app.js'.
npm ERR! This is most likely a problem with the NodejsStarterApp package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node app.js
npm ERR! You can get their info via:
npm ERR! npm owner ls NodejsStarterApp
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /home/vcap/app/npm-debug.log
2015/10/27 10:46:53 Fail to start the application runtime: The runtime cannot be started. Error: Runtime start script returns error 'exit status 1'. Please check the application logs for more details.
Restarting the runtime in debug mode...
scripts/stop: line 27: kill: (88) - No such process
kill -9 88
scripts/stop: line 32: kill: (88) - No such process
Starting app with 'node --debug=5858 app.js '
Debugger listening on port 5858
module.js:338
throw err;
^
Error: Cannot find module 'ibmbluemix'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/home/vcap/app/app.js:11:18)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
firstappli.mybluemix.net - [27/10/2015:11:01:33 +0000] "GET /bluemix-debug/manage/tools/runtime HTTP/1.1" 200 0 69 "-" "Jakarta Commons-HttpClient/3.1" 108.168.250.153:11163 x_forwarded_for:"198.11.229.213" vcap_request_id:2ce77b66-4cc0-403d-6558-a020a23e4b93 response_time:0.259158396 app_id:8a0df22f-7c18-476f-8dc0-91c3db946ac6
I don't understand, I've not tried to test the code in local but i'm surprise that nobody on internet had the same error that me. Maybe I have forgotten something obvious... Thanks for your help!
PS : I have not use the default space created but I create a new one (otherwise I cant't create node application), maybe there is some repercussion...
You need to add ibmbluemix as a dependency in your package.json file:
{
"name": "NodejsStarterApp",
"version": "0.0.1",
"description": "A sample nodejs app for Bluemix",
"scripts": {
"start": "node app.js"
},
"dependencies": {
"express": "4.12.x",
"cfenv": "1.0.x",
"ibmbluemix": "1.0.0"
},
"repository": {},
"engines": {
"node": "0.12.x"
}
}
If you want to try your application locally run the following commands after changing package.json file:
# npm install
# node app.js
Related
I found out the files included in the Github repo that used to connect to the Heroku server and substituted with my own package.json, flow .json, repo link in app.json. After deploying, I tried opening app and received an error from the logs window of Heroku CLI as below:
2021-04-13T10:22:01.693823+00:00 heroku[web.1]: Starting process with command `node --max-old-space-size=384 node_modules/node-red/red.js --settings ./settings.js --userDir ./`
2021-04-13T10:22:05.304911+00:00 heroku[web.1]: Process exited with status 1
2021-04-13T10:22:05.411606+00:00 heroku[web.1]: State changed from starting to crashed
2021-04-13T10:22:05.185490+00:00 app[web.1]: throw err;
2021-04-13T10:22:05.185491+00:00 app[web.1]: ^
2021-04-13T10:22:05.185491+00:00 app[web.1]:
2021-04-13T10:22:05.185492+00:00 app[web.1]: Error: Cannot find
module '/app/node_modules/node-red/red.js'
2021-04-13T10:22:05.185492+00:00 app[web.1]: at
Function.Module._resolveFilename
(internal/modules/cjs/loader.js:880:15)
2021-04-13T10:22:05.185492+00:00 app[web.1]: at
Function.Module._load (internal/modules/cjs/loader.js:725:27)
2021-04-13T10:22:05.185493+00:00 app[web.1]: at
Function.executeUserEntryPoint [as runMain]
(internal/modules/run_main.js:72:12)
2021-04-13T10:22:05.185494+00:00 app[web.1]: at
internal/main/run_main_module.js:17:47 {
2021-04-13T10:22:05.185494+00:00 app[web.1]: code:
'MODULE_NOT_FOUND',
2021-04-13T10:22:05.185495+00:00 app[web.1]: requireStack: []
2021-04-13T10:22:05.185495+00:00 app[web.1]: }
My Github repo link
Hope to get your help. Thanks.
You have removed Node-RED from the package.json, so since it's not installed it won't start.
{
"name": "node-red-project",
"description": "A Node-RED Project",
"version": "0.0.1",
"dependencies": {
"node-red-contrib-alarm": "~1.2.5",
"node-red-contrib-component-dashboard": "0.0.4",
"node-red-contrib-components": "~0.1.8",
"node-red-contrib-firebase": "~1.1.1",
"node-red-contrib-influxdb": "~0.5.1",
"node-red-contrib-mqtt-broker": "~0.2.4",
"node-red-contrib-remote": "~1.1.3",
"node-red-contrib-ttn": "~2.0.5",
"node-red-contrib-ui-svg": "~2.2.1",
"node-red-contrib-users": "~0.1.9",
"node-red-dashboard": "~2.14.0",
"node-red-node-ui-table": "~0.3.10"
}
}
If you want to add extra nodes, you need to add these to the list of dependencies in the existing package.json not just replace them.
{
"name": "nodered-heroku",
"version": "0.0.7",
"dependencies": {
"when": "3.7.8",
"nano": "8.2.2",
"feedparser":"2.2.10",
"node-red-dashboard":"2.23.3",
"redis":"3.0.2",
"node-red": "1.1.3",
"node-red-node-tail": "0.1.1",
"node-red-contrib-aedes": "0.3.6",
"node-red-contrib-blynk-ws": "1.0.3",
"node-red-node-email": "1.7.9",
"node-red-node-ui-list": "0.3.1",
"node-red-contrib-telegrambot": "8.4.0",
"node-red-contrib-alarm": "~1.2.5",
"node-red-contrib-component-dashboard": "0.0.4",
"node-red-contrib-components": "~0.1.8",
"node-red-contrib-firebase": "~1.1.1",
"node-red-contrib-influxdb": "~0.5.1",
"node-red-contrib-mqtt-broker": "~0.2.4",
"node-red-contrib-remote": "~1.1.3",
"node-red-contrib-ttn": "~2.0.5",
"node-red-contrib-ui-svg": "~2.2.1",
"node-red-contrib-users": "~0.1.9",
"node-red-node-ui-table": "~0.3.10"
}
}
I would also suggest you use the latest version of Node-RED (1.3.1 at time of posting) as 1.1.3 is VERY OLD
i have this problem when i require DBus from the dbus package
const { app, BrowserWindow } = require("electron");
const DBus = require('dbus');
app.whenReady().then(() => {
var win = new BrowserWindow({ width: 600, height: 500 });
win.loadFile('index.html');
win.webContents.openDevTools();
});
so when i execute this code i get this error :
> electron script.js
App threw an error during load
Error: Module did not self-register: '/home/bislem/projects/test/electron/node_modules/dbus/build/Release/dbus.node'.
at process.func [as dlopen] (electron/js2c/asar.js:140:31)
at Object.Module._extensions..node (internal/modules/cjs/loader.js:1196:18)
at Object.func [as .node] (electron/js2c/asar.js:140:31)
at Module.load (internal/modules/cjs/loader.js:981:32)
at Module._load (internal/modules/cjs/loader.js:881:14)
at Function.Module._load (electron/js2c/asar.js:769:28)
at Module.require (internal/modules/cjs/loader.js:1023:19)
at require (internal/modules/cjs/helpers.js:77:18)
at Object.<anonymous> (/home/bislem/projects/test/electron/node_modules/dbus/lib/dbus.js:3:13)
at Module._compile (internal/modules/cjs/loader.js:1145:30)
A JavaScript error occurred in the main process
Uncaught Exception:
Error: Module did not self-register: '/home/bislem/projects/test/electron/node_modules/dbus/build/Release/dbus.node'.
at process.func [as dlopen] (electron/js2c/asar.js:140:31)
at Object.Module._extensions..node (internal/modules/cjs/loader.js:1196:18)
at Object.func [as .node] (electron/js2c/asar.js:140:31)
at Module.load (internal/modules/cjs/loader.js:981:32)
at Module._load (internal/modules/cjs/loader.js:881:14)
at Function.Module._load (electron/js2c/asar.js:769:28)
at Module.require (internal/modules/cjs/loader.js:1023:19)
at require (internal/modules/cjs/helpers.js:77:18)
at Object.<anonymous> (/home/bislem/projects/test/electron/node_modules/dbus/lib/dbus.js:3:13)
at Module._compile (internal/modules/cjs/loader.js:1145:30)
I searched for this error and tried some solutions but none of them worked (npm rebuild,npm update,delete the node_modules folder then npm install,use a diffrent version of node using the nvm command), but when runing each package by his own, (run electron using the start script electron ., and run dbus with node script.js) they works correctly.
and there was this when installing the dbus package :
console when installing dbus, console when installing dbus part 2
my package.json file :
{
"name": "electrontest",
"version": "1.0.0",
"description": "",
"main": "script.js",
"scripts": {
"start": "electron script.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"bootstrap": "^4.5.3",
"dbus": "^1.0.7",
"electron": "^10.1.5"
}
}
so my question is what is the correct way to Build/Run such code ? || how to use these two packages side by side ?
You need to run
npm install --save-dev electron-rebuild && npx electron-rebuild
More on using native node modules in electron here
I am following a tutorial on nodejs and I get an error.
That's my server.js file:
const express = require("express");
const app = express();
app.listen("/", function(req, res){
res.send("<h1>Hello, there!</h1>")
});
app.listen("/contact", function(req, res){
res.send("Contact me at obiwankenobi#falcon.com")
});
app.listen(3000, function(){
console.log("Server started on port 3000")
});
That's my package.json file:
{
"name": "my-express-server",
"version": "1.0.0",
"description": "This is a project on how to start your own server.",
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js"
},
"author": "Adam Marasli-Zaade",
"license": "ISC",
"dependencies": {
"express": "^4.17.1"
}
}
And when I am hitting: node server.js, that's the error I am getting:
adam#Omen-hp:~/Desktop/Angela/my-express-server$ node server.js
events.js:174
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE: address already in use /
at Server.setupListenHandle [as _listen2] (net.js:1260:19)
at listenInCluster (net.js:1325:12)
at Server.listen (net.js:1423:5)
at Function.listen (/home/adam/Desktop/Angela/my-express-server/node_modules/express/lib/application.js:618:24)
at Object.<anonymous> (/home/adam/Desktop/Angela/my-express-server/server.js:5:5)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
Emitted 'error' event at:
at emitErrorNT (net.js:1304:8)
at process._tickCallback (internal/process/next_tick.js:63:19)
at Function.Module.runMain (internal/modules/cjs/loader.js:745:11)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)
System info:
./+o+- adam#Omen-hp
yyyyy- -yyyyyy+ OS: Ubuntu 19.10 eoan
://+//////-yyyyyyo Kernel: x86_64 Linux 5.3.0-26-generic
.++ .:/++++++/-.+sss/` Node Version: 10.15.2
.:++o: /++++++++/:--:/- NPM Version: 6.13.6
o:+o+:++.`..```.-/oo+++++/ Shell: bash 5.0.3
.:+o:+o/. `+sssoo+/
.++/+:+oo+o:` /sssooo.
/+++//+:`oo+o /::--:.
\+/+o+++`o++o ++////.
.++.o+++oo+:` /dddhhh.
.+.o+oo:. `oddhhhh+
\+.++o+o``-````.:ohdhhhhh+
`:o+++ `ohhhhhhhhyo++os: CPU: Intel Core i5-7300HQ # 4x 3.5GHz
.o:`.syhhhhhhh/.oo++o` GPU: GeForce GTX 1050
/osyyyyyyo++ooo+++/
````` +oo+++o\:
`oo++.
I have tried restarting the system, I have tried recreating the project, I have tried every command to find out what uses port:3000 and kill it, the problem is that I can't find anything that uses it, I have disabled atom-liver-server in case that's the problem because it uses port:3000, I don't know what else to do.
Thank your for your time.
Adam
Your probleme is this chunk:
app.listen("/", function(req, res){
res.send("<h1>Hello, there!</h1>")
});
You are trying to listen on a socket path.
I assume you want to use app.get(...).
Same for your /contact path
Take a short look on the express.js docs: https://expressjs.com/en/api.html#app.listen_path_callback
From the command line type:
pkill -9 node
then start up your prog
to see the port activity for your machine:
sudo lsof -iTCP -sTCP:LISTEN -n -P
// or for ubunut try below
netstat -anp | grep apache
When I start a dockerized Node.js testapp with
sudo docker-compose up
I get the following error:
Starting testapp_web_1 ... done
Attaching to testapp_web_1
web_1 |
web_1 | > testapp#0.0.1 start /usr/app
web_1 | > node index.js
web_1 |
web_1 | internal/modules/cjs/loader.js:613
web_1 | throw err;
web_1 | ^
web_1 |
web_1 | Error: Cannot find module 'mongodb'
web_1 | Require stack:
web_1 | - /usr/app/index.js
web_1 | at Function.Module._resolveFilename (internal/modules/cjs/loader.js:610:15)
web_1 | at Function.Module._load (internal/modules/cjs/loader.js:526:27)
web_1 | at Module.require (internal/modules/cjs/loader.js:666:19)
web_1 | at require (internal/modules/cjs/helpers.js:16:16)
web_1 | at Object.<anonymous> (/usr/app/index.js:4:21)
web_1 | at Module._compile (internal/modules/cjs/loader.js:759:30)
web_1 | at Object.Module._extensions..js (internal/modules/cjs/loader.js:770:10)
web_1 | at Module.load (internal/modules/cjs/loader.js:628:32)
web_1 | at Function.Module._load (internal/modules/cjs/loader.js:555:12)
web_1 | at Function.Module.runMain (internal/modules/cjs/loader.js:826:10)
web_1 | npm ERR! code ELIFECYCLE
web_1 | npm ERR! errno 1
web_1 | npm ERR! testapp#0.0.1 start: `node index.js`
web_1 | npm ERR! Exit status 1
web_1 | npm ERR!
web_1 | npm ERR! Failed at the testapp#0.0.1 start script.
web_1 | npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
web_1 |
web_1 | npm ERR! A complete log of this run can be found in:
web_1 | npm ERR! /root/.npm/_logs/2019-05-04T15_34_04_615Z-debug.log
testapp_web_1 exited with code 1
The project structur is as follows
- testapp
--- docker-compose.yml
--- dockerfile
--- src
----- index.js
----- package.json
index.js
'use strict';
const MongoClient = require('mongodb').MongoClient;
const express = require('express');
// Constants
const PORT = 8080;
// App
const app = express();
app.get('/', (req, res) => {
res.send('Hello world\n');
});
app.listen(PORT);
console.log(`Running on Port:${PORT}`);
package.json
{
"name": "testapp",
"version": "0.0.1",
"description": "Testapp",
"author": "hi there",
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"dependencies": {
"express": "^4.16.4",
"mongodb": "^3.2.3"
}
}
dockerfile
FROM node:12-alpine
WORKDIR /usr/app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 8080
docker-compose.yml
version: '3'
services:
web:
build: .
command: npm start
volumes:
- ./src:/usr/app/
- /usr/app/node_modules
ports:
- 80:8080
I have alread read this stackoverflow thread but I couldn't solve this issue. I'm getting this error no matter what module I'm trying to use: mongodb, spdy, etc. Locally without docker the testapp is working. But I don't know what I'm doing wrong with docker. Can anyone help me?
Have volume folder mapping for node_modules and ensure it has mongo folder copied / created
version: '3'
services:
web:
build: .
command: npm start
volumes:
- ./src:/usr/app/
- ./src/node_modules:/usr/app/node_modules
ports:
- 80:8080
Ref:https://morioh.com/p/42531a398049/containerizing-a-node-js-application-for-development-with-docker-compose
You need to drop & rebuild the anonymous volume holding the node_modules for the updates to package.json to take effect.
docker-compose rm -v
# then:
docker-compose build
docker-compose up
You will only have to do this for changes to node_modules, since the other volume is linked to your ./src/, and will reflect changes on the host.
I am learning ReactJS. The installation has been done but when I run this npm command, I get the following error.
me#R-SOFT-85:/var/www/reactjsbasics$ npm run build
> reactjsbasics#1.0.0 build /var/www/reactjsbasics
> webpack -d && cp src/index.html dist/index.html && webpack-dev-server --content-base src/ --inline --watch
/var/www/reactjsbasics/node_modules/webpack/bin/convert-argv.js:487
throw new Error("'output.filename' is required, either in config file or as --output-filename");
^
Error: 'output.filename' is required, either in config file or as --output-filename
at processOptions (/var/www/reactjsbasics/node_modules/webpack/bin/convert-argv.js:487:11)
at processConfiguredOptions (/var/www/reactjsbasics/node_modules/webpack/bin/convert-argv.js:136:4)
at module.exports (/var/www/reactjsbasics/node_modules/webpack/bin/convert-argv.js:112:10)
at Object.<anonymous> (/var/www/reactjsbasics/node_modules/webpack/bin/webpack.js:155:40)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.runMain (module.js:605:10)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! reactjsbasics#1.0.0 build: `webpack -d && cp src/index.html dist/index.html && webpack-dev-server --content-base src/ --inline --watch`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the reactjsbasics#1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
┌──────────────────────────────────────────────────────────┐
│ npm update check failed │
│ Try running with sudo or get access │
│ to the local update config store via │
│ sudo chown -R $USER:$(id -gn $USER) /home/me/.config │
└──────────────────────────────────────────────────────────┘
npm ERR! A complete log of this run can be found in:
npm ERR! /home/me/.npm/_logs/2017-07-18T06_15_33_602Z-debug.log
webpack.config.js
var webpack=require("webpack");
var path=require("path");
var DIST_DIR = path.resolve(__dirname,"dist");
var SRC_DIR = path.resolve(__dirname,"src");
var config={
entry:SRC_DIR + "/app/index.js",
output:{
path:DIST_DIR+"/app",
filename:"bundle.js",
publicPath:"/app/"
},
module:{
loaders:[
{
test:"/\.js?/",
include:SRC_DIR,
loader:"babel-loader",
query:{
presets:["react","es2015","stage-2"]
}
}
]
}
};
package.json
"scripts": {
"start":"npm run build",
"build":"webpack -d && cp src/index.html dist/index.html && webpack-dev-server --content-base src/ --inline --watch",
"build:prod":"webpack -p && cp src/index.html dist/index.html"
},
It looks like you have forgotten to export your config
// webpack.config.js
var config = {
...
};
// you need to export config object
module.exports = config