Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

npm start error #9

Open
liujunlingx opened this issue Dec 17, 2016 · 1 comment
Open

npm start error #9

liujunlingx opened this issue Dec 17, 2016 · 1 comment

Comments

@liujunlingx
Copy link

win10
npm 3.8.9
node v6.2.0
我切换分支后,再npm start报错,要怎么解决?

sanzhs@DESKTOP-TB810EH MINGW32 /e/RxJS/learning-rxjs (master)
$ git checkout seed
Branch seed set up to track remote branch seed from origin.
Switched to a new branch 'seed'

sanzhs@DESKTOP-TB810EH MINGW32 /e/RxJS/learning-rxjs (seed)
$ npm start

rxjs-todomvc@0.1.0 start E:\RxJS\learning-rxjs
webpack-dev-server --inline --colors --progress --display-error-details --display-cached --port 3000 --content-base src

'webpack-dev-server' ▒▒▒▒▒ڲ▒▒▒▒ⲿ▒▒▒Ҳ▒▒▒ǿ▒▒▒▒еij▒▒▒
▒▒▒▒▒▒▒▒▒ļ▒▒▒

npm ERR! Windows_NT 10.0.10240
npm ERR! argv "E:\nodejs\node.exe" "E:\nodejs\node_modules\npm\bin\npm-cli.js" "start"
npm ERR! node v6.2.0
npm ERR! npm v3.8.9
npm ERR! code ELIFECYCLE
npm ERR! rxjs-todomvc@0.1.0 start: webpack-dev-server --inline --colors --progress --display-error-details --display-cached --port 3000 --content-base src
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the rxjs-todomvc@0.1.0 start script 'webpack-dev-server --inline --colors --progress --display-error-details --display-cached --port 3000 --content-base src'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the rxjs-todomvc package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! webpack-dev-server --inline --colors --progress --display-error-details --display-cached --port 3000 --content-base src
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs rxjs-todomvc
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls rxjs-todomvc
npm ERR! There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! Please include the following file with any support request:
npm ERR! E:\RxJS\learning-rxjs\npm-debug.log

sanzhs@DESKTOP-TB810EH MINGW32 /e/RxJS/learning-rxjs (seed)

================
还有个小白问题,刚接触TypeScript和RxJS,不是很熟悉。
按官网的npm install rxjs-es安装后,自己编了hello.ts文件,内容如下:
import Rx from 'rxjs/Rx';

Rx.Observable.of(1,2,3)
.map(x => console.log(x));

tsc hello.ts编译之后生成hello.js,放在html的<script>里测试显示找不到这个依赖

Uncaught ReferenceError: require is not defined
at greeter.js:2

这个要怎么解决,是要在特定目录下写ts文件吗?

@Brooooooklyn
Copy link
Owner

第一个问题:在切换到 seed 分支后尝试先执行 npm install 后再执行 npm start

第二个问题: TypeScript 默认将代码编译成 commonjs 的引用格式,这是 nodejs 下使用的一种模块引用模式。 如果你想在浏览器内直接使用这种引用模式需要使用 webpack 或者 browserify 将文件打包成一份,或者使用 requirejssystemjs 等模块加载器在浏览器加载这些模块。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants