jaredpalmer / jaredpalmer/backpack
How to add NODE_PATH to in package.json?
- Dominant language
- JavaScript
- Stars
- 4.4k
- Forks
- 164
- PR merge metrics
- No merged PRs in 30d
Description
How do I add NODE_PATH in package.json?
Part of my packcage.json:
```
"dependencies": {
"axios": "^0.16.2",
"cross-env": "^5.0.1",
"koa": "^2.3.0",
"koa-mount": "^3.0.0",
"koa-static": "^4.0.1",
"koa-trie-router": "^2.1.5",
"mongodb": "^2.2.31",
"nuxt": "^1.0.0-rc3",
"socket.io": "^2.0.3"
},
"devDependencies": {
"babel-eslint": "^7.2.3",
"backpack-core": "^0.4.1"
},
"scripts": {
"test": "mocha --harmony",
"dev": "NODE_PATH=./app backpack dev",
"build": "nuxt build && backpack build",
"start": "cross-env NODE_ENV=production NODE_PATH=./app node build/main.js"
},
```
backpack.config.js:
```
module.exports = {
webpack: (config, options, webpack) => {
config.entry.main = './server/index.js'
return config
}
}
```
In my server.js:
```
import Koa from 'koa'
import { Nuxt, Builder } from 'nuxt'
import socket from 'socket.io'
import http from 'http'
import config from 'config' // this is './config' without NODE_PATH=./app
```
**Error** at `npm run dev`:
> This dependency was not found:
>
> * config in ./server/index.js
>
But if I run `npm start`, it is working fine.
Any ideas?
Contributor guide
Research direction
Start with the package.json scripts and backpack.config.js, then compare the dependency resolution used by npm run dev with npm start. Check server/index.js, especially the import of config; done would mean the development command resolves the same module without the reported dependency error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100