Open mahavira opened 8 years ago
Same here...
See #931 & #14 . To me it's some bug with cache & webpack-assets.json. @mahavira @t0x1c123
I fixed it by editing ApiClient.js to this -> `import superagent from 'superagent'; import config from '../config';
const methods = ['get', 'post', 'put', 'patch', 'del'];
export default class ApiClient {
formatUrl(path) {
const adjustedPath = path[0] !== '/' ? '/' + path : path;
if (SERVER) {
// Prepend host and port of the API server to the path.
return ${config.useSsl ? 'https' : 'http'}://
+ 'localhost:3030/api' + adjustedPath;
}
// Prepend /api
to relative URL, to proxy to API server.
return '/api' + adjustedPath;
}
constructor(req) { methods.forEach((method) => this[method] = (path, {params, data} = {}) => new Promise((resolve, reject) => { const request = superagentmethod; if (params) { request.query(params); } if (SERVER && req.get('cookie')) { request.set('cookie', req.get('cookie')); } if (data) { request.send(data); } request.end((err, {body} = {}) => err ? reject(body || err) : resolve(body)); })); } }
export function formatUrl(path) {
const adjustedPath = path[0] !== '/' ? '/' + path : path;
if (SERVER) {
// Prepend host and port of the API server to the path.
return ${config.useSsl ? 'https' : 'http'}://
+ 'localhost:3030/api' + adjustedPath;
}
// Prepend /api
to relative URL, to proxy to API server.
return '/api' + adjustedPath;
}
`
I had this ReferenceError: _ApiClient is not defined
problem on node v5.0.0
, then upgraded to v5.6.0
and now everything is fine.
I got this error once on app startup, then restarting the dev server removed it. No idea why, but I wasn't changing any library/node versions, just restarted the server. A caching bug as initially mentioned sounds like a likely culprit.
Similar experience to @DelvarWorld, only I had to reboot my Mac (10.10.5). Restarting server (npm run dev) didn't solve it for me. Been fine since.
I've tested this project example yesterday using Node v5.1.0 (npm v3.3.12): either the "prod" and the "dev" runtime failed on error (with 2 different kind of errors, including the ApiClient one for the "prod" runtime). Today i've upgraded my Node version to v5.7.1 (npm v3.6.0) and no more error appear both for "prod" & "dev" runtime.
Each test was made after a fresh installation : rimraf the cloned dir -> git clone this repo -> npm install -> npm start OR npm run dev.
Hope it will help the community use this well tailored-made starter kit, though I can't figure out what's the root cause of these errors.
I have experienced the same problem and I solve restarting the server. It's strange but... works fine!
npm
& node
;export default class ApiClient
in helpers/ApiClient.js
;I ran into the stated issue upon first run. After nvm install v5.6 && nvm use v5.6
and rebuilding my sass bindings with npm rebuild node-sass
I was able to get a clean build.
Also had this problem when running npm run dev
for the first time. Worked well once I ran npm run dev
for the second time. Didn't change anything.
Strange! The error has occurred sometimes, then it gone with the wind. The Environment
is the reason.
oh no.. it's back.. @erikras do you happen to have more insight, or remember who ended up tracking this down?
I think this has to do with which node version is being used at runtime?
I'm open to PRs that can track down and fix this problem. Someone may want to try bisecting the error.. I know this issue was addressed in the past.
I didn't experience the APIClient issue again (after having upgrading my Node & NPM to v5.7.1+) but I assume this PR should definitely solve the pb : #1113 (no more _ApiClient private ref required).
[1] ReferenceError: _ApiClient is not defined [1] at new _ApiClient (ApiClient.js:22:7) [1] at server.js:68:18 [1] at Layer.handle [as handle_request] (/Users/linmingxiong/www/examples/react-redux-universal-hot-example/node_modules/express/lib/router/layer.js:95:5) [1] at trim_prefix (/Users/linmingxiong/www/examples/react-redux-universal-hot-example/node_modules/express/lib/router/index.js:312:13) [1] at /Users/linmingxiong/www/examples/react-redux-universal-hot-example/node_modules/express/lib/router/index.js:280:7 [1] at Function.process_params (/Users/linmingxiong/www/examples/react-redux-universal-hot-example/node_modules/express/lib/router/index.js:330:12) [1] at next (/Users/linmingxiong/www/examples/react-redux-universal-hot-example/node_modules/express/lib/router/index.js:271:10) [1] at SendStream.error (/Users/linmingxiong/www/examples/react-redux-universal-hot-example/node_modules/serve-static/index.js:120:7) [1] at emitOne (events.js:77:13) [1] at SendStream.emit (events.js:169:7)