angular2通用-如何加载下划线
我正在尝试使用unserscore.js。如何导入angular2通用-如何加载下划线,angular,webpack,Angular,Webpack,我正在尝试使用unserscore.js。如何导入 npm install underscore --save import '../../node_modules/underscore/underscore.js'; import * as _ from 'underscore'; 在控制台中,我得到以下错误 ERROR in [default] /Users/Documents/frontend/greenlabel-material/src/app/service/pager.s
npm install underscore --save
import '../../node_modules/underscore/underscore.js';
import * as _ from 'underscore';
在控制台中,我得到以下错误
ERROR in [default] /Users/Documents/frontend/greenlabel-material/src/app/service/pager.service.ts:1:19
Cannot find module 'underscore'.
当我安装时,我有一个通用运行,只是重新加载。我仍然得到了上面的错误,但是下划线使用的代码仍然有效
当我关闭应用程序并再次启动时,我仍然会得到上述信息,但不会启动
~/Documents/frontend/dudelabel-material$ npm start
> universal-starter@2.0.0 prestart /Users/dude/Documents/frontend/dudelabel-material
> npm run build
> universal-starter@2.0.0 prebuild /Users/dude/Documents/frontend/dudelabel-material
> rimraf dist
> universal-starter@2.0.0 build /Users/dude/Documents/frontend/dudelabel-material
> webpack
Hash: dcf119e1b8926b7b46a312a731c0c7486ac21b4c
Version: webpack 2.1.0-beta.25
Child
Hash: dcf119e1b8926b7b46a3
Version: webpack 2.1.0-beta.25
Time: 9393ms
Asset Size Chunks Chunk Names
index.js 4.23 MB 0 [emitted] main
[397] ./src async 160 bytes {0} [built]
+ 680 hidden modules
ERROR in [default] /Users/dude/Documents/frontend/dudelabel-material/src/app/service/pager.service.ts:1:19
Cannot find module 'underscore'.
Child
Hash: 12a731c0c7486ac21b4c
Version: webpack 2.1.0-beta.25
Time: 4845ms
Asset Size Chunks Chunk Names
index.js 145 kB 0 [emitted] main
+ 47 hidden modules
ERROR in [default] /Users/dude/Documents/frontend/dudelabel-material/src/app/service/pager.service.ts:1:19
Cannot find module 'underscore'.
npm ERR! Darwin 16.1.0
npm ERR! argv "/usr/local/Cellar/node/6.5.0/bin/node" "/usr/local/bin/npm" "run" "build"
npm ERR! node v6.5.0
npm ERR! npm v3.10.3
npm ERR! code ELIFECYCLE
npm ERR! universal-starter@2.0.0 build: `webpack`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the universal-starter@2.0.0 build script 'webpack'.
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 universal-starter package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! webpack
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs universal-starter
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls universal-starter
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/dude/Documents/frontend/dudelabel-material/npm-debug.log
npm ERR! Darwin 16.1.0
npm ERR! argv "/usr/local/Cellar/node/6.5.0/bin/node" "/usr/local/bin/npm" "start"
npm ERR! node v6.5.0
npm ERR! npm v3.10.3
npm ERR! code ELIFECYCLE
npm ERR! universal-starter@2.0.0 prestart: `npm run build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the universal-starter@2.0.0 prestart script 'npm run build'.
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 universal-starter package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! npm run build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs universal-starter
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls universal-starter
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/dude/Documents/frontend/dudelabel-material/npm-debug.log
那么,如何使webpack、下划线一起工作?检查它是否出现在package.json中。我记得Webpack从那个里获取模块列表。检查它是否出现在package.json中。我记得,Webpack从那里获得模块列表。