当我在Django项目上运行npm start时,我一直在尝试解决错误消息。我使用了this tutorial by Keith Dechant。
在网上花了几个小时(搜索)后,我决定向你寻求帮助。这是我收到的错误消息:
[0] npm WARN invalid config loglevel="notice"
[2] npm WARN invalid config loglevel="notice"
[0]
[0] > my_project@1.0.0 css-watch C:\Users\ED\Environments\my_project\my_project
[0] > node-sass my_project/static/scss -o my_project/static/css --watch
[0]
[2]
[2] > my_project@1.0.0 browser-sync C:\Users\ED\Environments\my_project\my_project
[2] > browser-sync start --files "my_project/static/css/*.css, my_project/static/js/*.js, my_project/**/*.py, my_project/templates/*.html" --proxy 127.0.0.1:8000 --reload-delay=300 --reload-debounce=500
[2]
[0] fs.js:994
[0] binding.lstat(pathModule._makeLong(path), statValues);
[0] ^
[0]
[0] Error: ENOENT: no such file or directory, lstat 'C:\Users\ED\Environments\my_project\my_project\my_project\static\scss'
[0] at Error (native)
[0] at Object.fs.lstatSync (fs.js:994:11)
[0] at Object.module.exports.parseDir (C:\Users\ED\Environments\my_project\my_project\node_modules\sass-graph\sass-graph.js:153:10)
[0] at Object.watcher.reset (C:\Users\ED\Environments\my_project\my_project\node_modules\node-sass\lib\watcher.js:17:21)
[0] at watch (C:\Users\ED\Environments\my_project\my_project\node_modules\node-sass\bin\node-sass:260:20)
[0] at run (C:\Users\ED\Environments\my_project\my_project\node_modules\node-sass\bin\node-sass:319:5)
[0] at Object.<anonymous> (C:\Users\ED\Environments\my_project\my_project\node_modules\node-sass\bin\node-sass:405:3)
[0] at Module._compile (module.js:570:32)
[0] at Object.Module._extensions..js (module.js:579:10)
[0] at Module.load (module.js:487:32)
[0] npm ERR! code ELIFECYCLE
[0] npm ERR! errno 1
[0] npm ERR! my_project@1.0.0 css-watch: `node-sass my_project/static/scss -o my_project/static/css --watch`
[0] npm ERR! Exit status 1
[0] npm ERR!
[0] npm ERR! Failed at the my_project@1.0.0 css-watch script.
[0] npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
[0]
[0] npm ERR! A complete log of this run can be found in:
[0] npm ERR! C:\Users\ED\AppData\Roaming\npm-cache\_logs\2018-06-12T14_49_28_316Z-debug.log
[0] npm run css-watch exited with code 1
--> Sending SIGTERM to other processes..
[1] python manage.py runserver exited with code 1
[2] npm run browser-sync exited with code 1
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! my_project@1.0.0 start: `concurrently --kill-others "npm run css-watch" "python manage.py runserver" "npm run browser-sync" `
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the my_project@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\ED\AppData\Roaming\npm-cache\_logs\2018-06-12T14_49_28_559Z-debug.log
之前有没有人遇到过类似的问题?在线搜索并没有落在任何有希望的地方
答案 0 :(得分:0)
使用gulp时,我能够使浏览器同步工作。步骤如下:
使用-g将gulp全局安装:
npm install -g gulp
将以下内容添加到gulpfile.js:
var gulp = require('gulp');
var browserSync = require('browser-sync').create();
var sass = require('gulp-sass');
var exec = require('child_process').exec;
// Compile sass into CSS & auto-inject into browsers:
gulp.task('sass', function() {
return gulp.src(['node_modules/bootstrap/scss/bootstrap.scss', 'static/scss/*.scss'])
.pipe(sass())
.pipe(gulp.dest("static/css"))
.pipe(browserSync.reload({stream: true}))
});
// Play nice with Django development server
gulp.task('runserver', function() {
var proc = exec('python manage.py runserver 9000')
});
gulp.task('browserSync', ['runserver'], function() {
browserSync.init({
notify: false,
port: 9000,
proxy: 'localhost:9000'
})
});
// Move the javascript files into our static/js folder
gulp.task('js', function() {
return gulp.src([ 'node_modules/bootstrap/dist/js/bootstrap.min.js', 'node_modules/jquery/dist/jquery.min.js', 'node_modules/tether/dist/js/tether.min.js'])
.pipe(gulp.dest("static/js"))
.pipe(browserSync.stream());
});
// Serving:
gulp.task('serve', ['browserSync', 'sass'], function() {
gulp.watch('static/scss/*.scss', ['sass']);
gulp.watch('static/js/*.js', browserSync.reload);
gulp.watch('templates/*.html', browserSync.reload);
});
gulp.task("default", function () {
gulp.start("serve");
});