There are lots of moving parts for this question so I will post everything. I am running npm run build and I get the following:
Here is my build script in package.json file:
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build":"browserify -d app/scripts/src/main.js -o app/scripts/dist/main.js"
},
"browserify":{
"transform":[
"babelify",{"presets":["es2015"],"sourceMap":true}
]
},
app.js:
class ChatApp {
constructor() {
console.log("Hello World")
}
}
export default ChatApp
main.js:
import ChatApp from './app'
new ChatApp()
Node version: 6.9.4
Browserify version: 14.3.0
UPDATE:
I updated it and still same result.
"build":"browserify app/scripts/src/main.js -d -o app/scripts/dist/main.js"
This also does not work and gives the same error:
"build":"browserify app/scripts/src/main.js > app/scripts/dist/main.js -d -o"
Also this same result:
"build":"browserify app/scripts/src/main.js > app/scripts/dist/main.js"
UPDATE: Running only the Browserify command from terminal
browserify app/scripts/src/main.js app/scripts/dist/main.js -d -o
TypeError: Path must be a string.
at resolve (/usr/local/lib/node_modules/browserify/node_modules/resolve/lib/async.js:15:19)
at nr (/usr/local/lib/node_modules/browserify/node_modules/module-deps/index.js:282:24)
at /usr/local/lib/node_modules/browserify/node_modules/resolve/lib/async.js:17:13
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)
I was able to reproduce your error and fixed it by changing the browserify section of your package.json file (note how there's a nested array).
{
"scripts": {
"build": "browserify -d app/scripts/src/main.js -o app/scripts/dist/main.js"
},
"browserify": {
"transform": [ [ "babelify", { "presets": [ "es2015" ], "sourceMap": true } ] ]
},
"dependencies": {
"babel-preset-es2015": "^6.24.1",
"babelify": "^7.3.0"
}
}